diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2001-11-12 18:56:49 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2001-11-12 18:56:49 +0000 |
| commit | 5b29d6e9065503829735e5d07a827ef64743c929 (patch) | |
| tree | 6784b34e0d65d632d9d07c0889679e638d222d5f | |
| parent | d9009094398fbdf0e79e8fa16ce715f9f2ab25f7 (diff) | |
Notes
| -rw-r--r-- | sys/kern/kern_proc.c | 16 | ||||
| -rw-r--r-- | sys/kern/kern_prot.c | 3 |
2 files changed, 10 insertions, 9 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 6647f73785d7..4b1f49281861 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -183,16 +183,14 @@ int inferior(p) register struct proc *p; { - int rval; + int rval = 1; - PROC_LOCK_ASSERT(p, MA_OWNED); - if (p == curproc) - return (1); - if (p->p_pid == 0) - return (0); - PROC_LOCK(p->p_pptr); - rval = inferior(p->p_pptr); - PROC_UNLOCK(p->p_pptr); + sx_assert(&proctree_lock, SX_LOCKED); + for (; p != curproc; p = p->p_pptr) + if (p->p_pid == 0) { + rval = 0; + break; + } return (rval); } diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 5ffeeb79fc1f..9378d486a62e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -55,6 +55,7 @@ #include <sys/lock.h> #include <sys/mutex.h> #include <sys/proc.h> +#include <sys/sx.h> #include <sys/sysproto.h> #include <sys/malloc.h> #include <sys/pioctl.h> @@ -443,6 +444,7 @@ setpgid(td, uap) mtx_lock(&Giant); + sx_slock(&proctree_lock); if (uap->pid != 0 && uap->pid != curp->p_pid) { if ((targp = pfind(uap->pid)) == NULL || !inferior(targp)) { if (targp) @@ -488,6 +490,7 @@ setpgid(td, uap) PROC_UNLOCK(targp); error = enterpgrp(targp, uap->pgid, 0); done2: + sx_sunlock(&proctree_lock); mtx_unlock(&Giant); return (error); } |
