Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 2019 09:29:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r351210 - head/tests/sys/kern
Message-ID:  <201908190929.x7J9TReK085223@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908190929.x7J9TReK085223>