diff options
author | jhb <jhb@FreeBSD.org> | 2018-01-24 00:32:02 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2018-01-24 00:32:02 +0000 |
commit | f9f4a0300919e86977a1740b4487b61a69657ee4 (patch) | |
tree | 029c2cf0d64fe9ec04bc40611476d64987c3743c | |
parent | 4b5f327f45155d8198f121b8c70ba8d012467c6d (diff) | |
download | FreeBSD-src-f9f4a0300919e86977a1740b4487b61a69657ee4.zip FreeBSD-src-f9f4a0300919e86977a1740b4487b61a69657ee4.tar.gz |
MFC 326953:
Catch up to r325719 which makes the kern.proc.pid sysctl "work" for zombies.
Some of the ptrace tests need to wait for a child process to become a
zombie before preceding. The parent process polls the child process
via the kern.proc.pid sysctl to wait for it to become a zombie.
Previously the code polled until the sysctl failed with ESRCH. Now it
will poll until either the sysctl fails with ESRCH (for compatiblity
with older kernels) or returns a kinfo_proc structure with the ki_stat
field set to SZOMB.
-rw-r--r-- | tests/sys/kern/ptrace_test.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c index 167a94f..d7b3222 100644 --- a/tests/sys/kern/ptrace_test.c +++ b/tests/sys/kern/ptrace_test.c @@ -104,6 +104,10 @@ wait_for_zombie(pid_t pid) /* * Wait for a process to exit. This is kind of gross, but * there is not a better way. + * + * Prior to r325719, the kern.proc.pid.<pid> sysctl failed + * with ESRCH. After that change, a valid struct kinfo_proc + * is returned for zombies with ki_stat set to SZOMB. */ for (;;) { struct kinfo_proc kp; @@ -116,10 +120,11 @@ wait_for_zombie(pid_t pid) mib[3] = pid; len = sizeof(kp); if (sysctl(mib, nitems(mib), &kp, &len, NULL, 0) == -1) { - /* The KERN_PROC_PID sysctl fails for zombies. */ ATF_REQUIRE(errno == ESRCH); break; } + if (kp.ki_stat == SZOMB) + break; usleep(5000); } } |