From 39ba52c0b74ede73f9e35f2633091e5a74cae4d5 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 19 Aug 2019 09:29:27 +0000 Subject: [PATCH] sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach ptrace(PT_DETACH) requires stopped debuggee, otherwise it fails. When the call fails, the C process is left as debuggee of the process D, and might be killed too early if process D exits occurs fast enough. Since pipes are not closed in the forked children, this resulted in the test hanging, since no write occured from C to wake A. PR: 237657 Reported and tested by: lwhsu Sponsored by: The FreeBSD Foundation MFC after: 1 week --- tests/sys/kern/pdeathsig.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/sys/kern/pdeathsig.c b/tests/sys/kern/pdeathsig.c index a69720dce0e2..749f413d3635 100644 --- a/tests/sys/kern/pdeathsig.c +++ b/tests/sys/kern/pdeathsig.c @@ -305,7 +305,9 @@ ATF_TC_BODY(signal_delivered_ptrace, tc) WSTOPSIG(status)); assert(rc == 0); - ptrace(PT_DETACH, c_pid, 0, 0); + waitpid(c_pid, &status, 0); + if (!WIFEXITED(status)) + ptrace(PT_DETACH, c_pid, 0, 0); _exit(0); }