diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2004-08-14 17:15:16 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2004-08-14 17:15:16 +0000 |
| commit | 6cbea71c828c3ff2fb612997fd1ec0cf66f17393 (patch) | |
| tree | cdaca99d871147747d09c1bfb4d8e90cdc42754a | |
| parent | f13a7951e13dc2b2171de6ca0ccde037fb0a624f (diff) | |
Notes
| -rw-r--r-- | sys/kern/kern_proc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 7177d050b253..b1445438877a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -242,7 +242,10 @@ inferior(p) } /* - * Locate a process by number + * Locate a process by number; return only "live" processes -- i.e., neither + * zombies nor newly born but incompletely initialized processes. By not + * returning processes in the PRS_NEW state, we allow callers to avoid + * testing for that condition to avoid dereferencing p_ucred, et al. */ struct proc * pfind(pid) @@ -253,6 +256,10 @@ pfind(pid) sx_slock(&allproc_lock); LIST_FOREACH(p, PIDHASH(pid), p_hash) if (p->p_pid == pid) { + if (p->p_state == PRS_NEW) { + p = NULL; + break; + } PROC_LOCK(p); break; } |
