Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 May 2015 19:43:36 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283836 - head/tests/sys/kern
Message-ID:  <201505311943.t4VJhand041978@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sun May 31 19:43:35 2015
New Revision: 283836
URL: https://svnweb.freebsd.org/changeset/base/283836

Log:
  Consistently only use one end of the pipe in the parent and debugger
  processes and do not rely on EOF due to a close() in the debugger.
  
  PR:		200489
  Differential Revision:	https://reviews.freebsd.org/D2674
  Reviewed by:	kib, ngie, rodrigc

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

Modified: head/tests/sys/kern/ptrace_test.c
==============================================================================
--- head/tests/sys/kern/ptrace_test.c	Sun May 31 19:09:24 2015	(r283835)
+++ head/tests/sys/kern/ptrace_test.c	Sun May 31 19:43:35 2015	(r283836)
@@ -304,7 +304,7 @@ ATF_TC_BODY(ptrace__parent_sees_exit_aft
 		ATF_REQUIRE(write(dpipe[1], &c, sizeof(c)) == sizeof(c));
 
 		/* Wait for parent's failed wait. */
-		ATF_REQUIRE(read(dpipe[1], &c, sizeof(c)) == 0);
+		ATF_REQUIRE(read(dpipe[1], &c, sizeof(c)) == sizeof(c));
 
 		wpid = waitpid(child, &status, 0);
 		ATF_REQUIRE(wpid == child);
@@ -313,6 +313,7 @@ ATF_TC_BODY(ptrace__parent_sees_exit_aft
 
 		exit(0);
 	}
+	close(dpipe[1]);
 
 	/* Parent process. */
 
@@ -365,10 +366,11 @@ ATF_TC_BODY(ptrace__parent_sees_exit_aft
 	ATF_REQUIRE(wpid == 0);
 
 	/* Signal the debugger to wait for the child. */
-	close(dpipe[0]);
+	ATF_REQUIRE(write(dpipe[0], &c, sizeof(c)) == sizeof(c));
 
 	/* Wait for the debugger. */
-	ATF_REQUIRE(read(dpipe[1], &c, sizeof(c)) == 0);
+	ATF_REQUIRE(read(dpipe[0], &c, sizeof(c)) == 0);
+	close(dpipe[0]);
 
 	/* The child process should now be ready. */
 	wpid = waitpid(child, &status, WNOHANG);



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