[PATCH] off-by-one bug in do_process_times() in kernel/sched.c

Vitezslav Samel (vsamel@seznam.cz)
Wed, 8 Sep 1999 16:41:51 +0200


Hi!

When using 'ulimit -t 10' for a long-running process, it was killed right
after 11 secs.

Here's a two-line patch:

diff -urN clean-2.3.16/kernel/sched.c linux/kernel/sched.c
--- clean-2.3.16/kernel/sched.c Thu Aug 26 19:43:59 1999
+++ linux/kernel/sched.c Tue Sep 7 21:50:44 1999
@@ -1185,12 +1185,12 @@

psecs = (p->times.tms_utime += user);
psecs += (p->times.tms_stime += system);
- if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_cur) {
+ if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_cur) {
/* Send SIGXCPU every second.. */
if (!(psecs % HZ))
send_sig(SIGXCPU, p, 1);
/* and SIGKILL when we go over max.. */
- if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_max)
+ if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_max)
send_sig(SIGKILL, p, 1);
}
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/