summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2011-09-17 19:55:32 +0000
committertrasz <trasz@FreeBSD.org>2011-09-17 19:55:32 +0000
commit885c3974292380cb965fd99f2a4371e9e3225697 (patch)
tree195bcf812044f53fbd8420e9df679c97560bf120 /sys/kern/kern_exit.c
parent71b574423035f1fdf0afadd60afd9789d1cd3753 (diff)
downloadFreeBSD-src-885c3974292380cb965fd99f2a4371e9e3225697.zip
FreeBSD-src-885c3974292380cb965fd99f2a4371e9e3225697.tar.gz
Fix long-standing thinko regarding maxproc accounting. Basically,
we were accounting the newly created process to its parent instead of the child itself. This caused problems later, when the child changed its credentials - the per-uid, per-jail etc counters were not properly updated, because the maxproc counter in the child process was 0. Approved by: re (kib)
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 9be54de..49192bf 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -765,12 +765,12 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options,
/*
* Destroy resource accounting information associated with the process.
*/
- racct_proc_exit(p);
#ifdef RACCT
- PROC_LOCK(p->p_pptr);
- racct_sub(p->p_pptr, RACCT_NPROC, 1);
- PROC_UNLOCK(p->p_pptr);
+ PROC_LOCK(p);
+ racct_sub(p, RACCT_NPROC, 1);
+ PROC_UNLOCK(p);
#endif
+ racct_proc_exit(p);
/*
* Free credentials, arguments, and sigacts.
@@ -929,25 +929,13 @@ loop:
void
proc_reparent(struct proc *child, struct proc *parent)
{
-#ifdef RACCT
- int locked;
-#endif
sx_assert(&proctree_lock, SX_XLOCKED);
PROC_LOCK_ASSERT(child, MA_OWNED);
if (child->p_pptr == parent)
return;
-#ifdef RACCT
- locked = PROC_LOCKED(parent);
- if (!locked)
- PROC_LOCK(parent);
- racct_add_force(parent, RACCT_NPROC, 1);
- if (!locked)
- PROC_UNLOCK(parent);
-#endif
PROC_LOCK(child->p_pptr);
- racct_sub(child->p_pptr, RACCT_NPROC, 1);
sigqueue_take(child->p_ksi);
PROC_UNLOCK(child->p_pptr);
LIST_REMOVE(child, p_sibling);
OpenPOWER on IntegriCloud