| 435 | * testing for that condition to avoid dereferencing p_ucred, et al. |
| 436 | */ |
| 437 | static __always_inline struct proc * |
| 438 | _pfind(pid_t pid, bool zombie) |
| 439 | { |
| 440 | struct proc *p; |
| 441 | |
| 442 | p = curproc; |
| 443 | if (p->p_pid == pid) { |
| 444 | PROC_LOCK(p); |
| 445 | return (p); |
| 446 | } |
| 447 | sx_slock(PIDHASHLOCK(pid)); |
| 448 | LIST_FOREACH(p, PIDHASH(pid), p_hash) { |
| 449 | if (p->p_pid == pid) { |
| 450 | PROC_LOCK(p); |
| 451 | if (p->p_state == PRS_NEW || |
| 452 | (!zombie && p->p_state == PRS_ZOMBIE)) { |
| 453 | PROC_UNLOCK(p); |
| 454 | p = NULL; |
| 455 | } |
| 456 | break; |
| 457 | } |
| 458 | } |
| 459 | sx_sunlock(PIDHASHLOCK(pid)); |
| 460 | return (p); |
| 461 | } |
| 462 | |
| 463 | struct proc * |
| 464 | pfind(pid_t pid) |