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
This commit is contained in:
Konstantin Belousov 2019-08-19 09:29:27 +00:00
parent 55d26365b1
commit 39ba52c0b7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=351210

View File

@ -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);
}