aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2018-12-28 13:32:14 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2018-12-28 13:32:14 +0000
commit0abc7e41baf2e7700d5bf28e7193e65a7364b6d6 (patch)
treeb331a987d38d50a9f52be4999f7c91c0110ddb6b
parent003fdafbea1a788195114c28bf6a56e195e3a954 (diff)
downloadsrc-0abc7e41baf2e7700d5bf28e7193e65a7364b6d6.tar.gz
src-0abc7e41baf2e7700d5bf28e7193e65a7364b6d6.zip
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
Notes
Notes: svn path=/head/; revision=342572
-rw-r--r--sys/kern/kern_proc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 351f64630932..036e8ed6af63 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -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;
}