svn commit: r351211 - head/tests/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Mon Aug 19 09:33:10 UTC 2019
Author: kib
Date: Mon Aug 19 09:33:09 2019
New Revision: 351211
URL: https://svnweb.freebsd.org/changeset/base/351211
Log:
sys.kern.pdeathsig.signal_delivered_ptrace: fix startup.
Inform D that C executed procctl(PROC_PDEATHSIG_CTL). Otherwise D
might allow B to exit before C is set up to receive a signal on the
parent exit. In this case, C waits forever for the signal and test
hangs.
PR: 237657
Reported and tested by: lwhsu
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Modified:
head/tests/sys/kern/pdeathsig.c
Modified: head/tests/sys/kern/pdeathsig.c
==============================================================================
--- head/tests/sys/kern/pdeathsig.c Mon Aug 19 09:29:27 2019 (r351210)
+++ head/tests/sys/kern/pdeathsig.c Mon Aug 19 09:33:09 2019 (r351211)
@@ -229,6 +229,7 @@ ATF_TC_BODY(signal_delivered_ptrace, tc)
int rc;
int pipe_ca[2];
int pipe_db[2];
+ int pipe_cd[2];
char buffer;
int status;
@@ -236,6 +237,8 @@ ATF_TC_BODY(signal_delivered_ptrace, tc)
ATF_REQUIRE(rc == 0);
rc = pipe(pipe_db);
ATF_REQUIRE(rc == 0);
+ rc = pipe(pipe_cd);
+ assert(rc == 0);
rc = fork();
ATF_REQUIRE(rc != -1);
@@ -263,6 +266,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc)
rc = procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &signum);
assert(rc == 0);
+ rc = write(pipe_cd[1], "x", 1);
+ assert(rc == 1);
+
/* wait for B to die and signal us... */
signum = 0xdeadbeef;
rc = sigwait(&sigset, &signum);
@@ -292,6 +298,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc)
rc = ptrace(PT_CONTINUE, c_pid, (caddr_t) 1, 0);
assert(rc == 0);
+
+ rc = read(pipe_cd[0], &buffer, 1);
+ assert(rc == 1);
/* tell B that we're ready for it to exit now */
rc = write(pipe_db[1], ".", 1);
More information about the svn-src-all
mailing list