From de567a4bef606b118b5f771c863980c3206d781c Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 19 Aug 2019 09:33:09 +0000 Subject: [PATCH] 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 --- tests/sys/kern/pdeathsig.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/sys/kern/pdeathsig.c b/tests/sys/kern/pdeathsig.c index 749f413d3635..34c9adef577c 100644 --- a/tests/sys/kern/pdeathsig.c +++ b/tests/sys/kern/pdeathsig.c @@ -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); @@ -293,6 +299,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); assert(rc == 1);