summaryrefslogtreecommitdiff
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2005-03-07 18:17:44 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-07 18:17:44 -0800
commit9046dd435b58f6118d9fa5a9ab2e51ba4e0e9c93 (patch)
tree9aa1839f6f3e34c59d6dbb4d14564ed4f4760edf /kernel/fork.c
parentd80d30ff8b9122aa51135e942e35566904f32ee5 (diff)
[PATCH] make RLIMIT_CPU/SIGXCPU per-process
POSIX requires that the RLIMIT_CPU resource limit that generates SIGXCPU be counted on a per-process basis. Currently, Linux implements this for individual threads. This patch fixes the semantics to conform with POSIX. The essential machinery for the process CPU limit is is tied into the new posix-timers code for process CPU clocks and timers. Signed-off-by: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 37d6b4769965..3a3b19a98c4e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -768,6 +768,15 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
task_unlock(current->group_leader);
+ if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
+ /*
+ * New sole thread in the process gets an expiry time
+ * of the whole CPU time limit.
+ */
+ tsk->it_prof_expires =
+ secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
+ }
+
return 0;
}
@@ -1032,6 +1041,7 @@ static task_t *copy_process(unsigned long clone_flags,
cputime_zero) ||
!cputime_eq(current->signal->it_prof_expires,
cputime_zero) ||
+ current->signal->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY ||
!list_empty(&current->signal->cpu_timers[0]) ||
!list_empty(&current->signal->cpu_timers[1]) ||
!list_empty(&current->signal->cpu_timers[2])) {