pfind, pfind_any: Correct zombie logic

SVN r340744 erroneously changed pfind() to return any process including
zombies and pfind_any() to return only non-zombie processes.

In particular, this caused kill() on a zombie process to fail with [ESRCH].
There is no direct test case for this but /usr/tests/bin/sh/builtins/kill1.0
occasionally triggers it (as reported by lwhsu).

Conversely, returning zombies from pfind() seems likely to violate
invariants and cause panics, but I have not looked at this.

PR:		233646
Reviewed by:	mjg, kib, ngie
Differential Revision:	https://reviews.freebsd.org/D18665
This commit is contained in:
Jilles Tjoelker 2018-12-28 13:32:14 +00:00
parent 003fdafbea
commit 0abc7e41ba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=342572

View File

@ -388,7 +388,7 @@ _pfind(pid_t pid, bool zombie)
if (p->p_pid == pid) {
PROC_LOCK(p);
if (p->p_state == PRS_NEW ||
(zombie && p->p_state == PRS_ZOMBIE)) {
(!zombie && p->p_state == PRS_ZOMBIE)) {
PROC_UNLOCK(p);
p = NULL;
}