From owner-svn-src-all@freebsd.org Wed Jan 24 00:32:03 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB536ED59A8; Wed, 24 Jan 2018 00:32:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 989FA6EBB3; Wed, 24 Jan 2018 00:32:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93A47165DB; Wed, 24 Jan 2018 00:32:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0O0W2Kd047620; Wed, 24 Jan 2018 00:32:02 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0O0W2AU047619; Wed, 24 Jan 2018 00:32:02 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201801240032.w0O0W2AU047619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 24 Jan 2018 00:32:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r328309 - in stable: 10/tests/sys/kern 11/tests/sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/tests/sys/kern 11/tests/sys/kern X-SVN-Commit-Revision: 328309 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 00:32:03 -0000 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/10/tests/sys/kern/ptrace_test.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/10/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/10/tests/sys/kern/ptrace_test.c Wed Jan 24 00:11:46 2018 (r328308) +++ stable/10/tests/sys/kern/ptrace_test.c Wed Jan 24 00:32:02 2018 (r328309) @@ -103,6 +103,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. 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; @@ -115,10 +119,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); } }