Author: kib
Date: Mon Aug 19 09:29:27 2019
New Revision: 351210
URL: https://svnweb.freebsd.org/changeset/base/351210

Log:
  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

Modified:
  head/tests/sys/kern/pdeathsig.c

Modified: head/tests/sys/kern/pdeathsig.c
==============================================================================
--- head/tests/sys/kern/pdeathsig.c     Mon Aug 19 07:47:09 2019        
(r351209)
+++ head/tests/sys/kern/pdeathsig.c     Mon Aug 19 09:29:27 2019        
(r351210)
@@ -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);
                }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to