Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Jan 2018 00:32:02 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328309 - in stable: 10/tests/sys/kern 11/tests/sys/kern
Message-ID:  <201801240032.w0O0W2GD047625@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jan 24 00:32:02 2018
New Revision: 328309
URL: https://svnweb.freebsd.org/changeset/base/328309

Log:
  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.

Modified:
  stable/11/tests/sys/kern/ptrace_test.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/tests/sys/kern/ptrace_test.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/tests/sys/kern/ptrace_test.c
==============================================================================
--- stable/11/tests/sys/kern/ptrace_test.c	Wed Jan 24 00:11:46 2018	(r328308)
+++ stable/11/tests/sys/kern/ptrace_test.c	Wed Jan 24 00:32:02 2018	(r328309)
@@ -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);
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801240032.w0O0W2GD047625>