From owner-freebsd-bugs Fri May 11 2:20:11 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id F15E937B423 for ; Fri, 11 May 2001 02:20:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f4B9K4f54827; Fri, 11 May 2001 02:20:04 -0700 (PDT) (envelope-from gnats) Date: Fri, 11 May 2001 02:20:04 -0700 (PDT) Message-Id: <200105110920.f4B9K4f54827@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Peter Pentchev Subject: Re: kern/27262: process won't be terminated after CPUTIME exceeded Reply-To: Peter Pentchev Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/27262; it has been noted by GNATS. From: Peter Pentchev To: in@amalea.org Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: kern/27262: process won't be terminated after CPUTIME exceeded Date: Fri, 11 May 2001 12:18:53 +0300 On Fri, May 11, 2001 at 12:00:52PM +0800, in@amalea.org wrote: > > >Number: 27262 > >Category: kern > >Synopsis: process won't be terminated after CPUTIME exceeded > >Originator: in@amalea.org > >Release: FreeBSD 5.0-CURRENT i386 > >Organization: > International Amalea Organization > >Environment: > System: FreeBSD dns.amalea.org 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon May 7 22:33:41 CST 2001 in@dns.amalea.org:/usr/obj/usr/src/sys/GENERIC i386 > > > CPU: Pentium III/Pentium III Xeon/Celeron (733.36-MHz 686-class CPU) > FreeBSD 5.0-CURRENT i386 > > >Description: > > process which exceeds CPUTIME limit by setrlimit() > will not receive signal SIGXCPU and terminate. Confirmed. The attached program's output on RELENG_4 (correct): $ time ./foo before: cur = 7FFFFFFFFFFFFFFF, max = 7FFFFFFFFFFFFFFF Setting CPU limit to cur 2, max 5.. after: cur = 2, max = 5 Entering loop.. time: command terminated abnormally 2.02 real 2.01 user 0.00 sys Cputime limit exceeded $ ..and on ref5.FreeBSD.org (-current, after waiting a while and hitting ^C): $ time ./foo before: cur = 7FFFFFFFFFFFFFFF, max = 7FFFFFFFFFFFFFFF Setting CPU limit to cur 2, max 5.. after: cur = 2, max = 5 Entering loop.. ^CGot signal 2 User: (3, 799606) System: (0, 7850) 3.800u 0.007s 0:06.08 62.5% 5+178k 0+0io 0pf+0w $ Something's definitely wrong with -current's setrlimit().. G'luck, Peter -- If this sentence didn't exist, somebody would have invented it. #include #include #include #include #include #include static volatile int sig, sigflag; static void getlim(const char *, int); static void setlim(const char *, int, quad_t, quad_t); static void handler(int); static void getlim(const char *s, int resource) { struct rlimit rlp; if (getrlimit(resource, &rlp) < 0) err(1, "getrlimit(%s)", s); printf("%s: cur = %llX, max = %llX\n", s, rlp.rlim_cur, rlp.rlim_max); } static void setlim(const char *s, int resource, quad_t lcur, quad_t lmax) { struct rlimit rlp; printf("Setting %s limit to cur %llX, max %llX..\n", s, lcur, lmax); rlp.rlim_cur = (quad_t) lcur; rlp.rlim_max = (quad_t) lmax; if (setrlimit(resource, &rlp) < 0) err(1, "setrlimit(%s)", s); } static void handler(int signum __unused) { sig = signum; sigflag = 1; } static void showrusage(void) { struct rusage ru; if (getrusage(RUSAGE_SELF, &ru) < 0) err(1, "getrusage()"); printf("User: (%ld, %ld)\nSystem: (%ld, %ld)\n", ru.ru_utime.tv_sec, ru.ru_utime.tv_usec, ru.ru_stime.tv_sec, ru.ru_stime.tv_usec); } int main(void) { getlim("before", RLIMIT_CPU); setlim("CPU", RLIMIT_CPU, 2, 5); getlim("after", RLIMIT_CPU); printf("Entering loop..\n"); sig = 0; signal(SIGINT, handler); while (!sig) ; printf("Got signal %d\n", sig); showrusage(); return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message