Module Name:    src
Committed By:   kamil
Date:           Mon Nov 14 00:18:33 UTC 2016

Modified Files:
        src/tests/kernel: t_ptrace_wait.c

Log Message:
Enhance pipe(2)-based IPC barrier in attach5 of t_ptrace_wait

The write(2) call does not block and there is need to perform handshake, in
order to wait on the read(2) call.

The pipe(2) interface for IPC purposes is quite difficult to design and get
right. It might be refactored and with added new helper functions, although
it would be better to switch to some other mechanism rather. But as it
works now quite well in the current set of tests, do not touch it.

Sponsored by <The NetBSD Foundation>.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.11 src/tests/kernel/t_ptrace_wait.c:1.12
--- src/tests/kernel/t_ptrace_wait.c:1.11	Sat Nov 12 20:56:49 2016
+++ src/tests/kernel/t_ptrace_wait.c	Mon Nov 14 00:18:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.11 2016/11/12 20:56:49 christos Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.12 2016/11/14 00:18:33 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.11 2016/11/12 20:56:49 christos Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.12 2016/11/14 00:18:33 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1041,6 +1041,10 @@ ATF_TC_BODY(attach5, tc)
 		/* Emit message to the parent */
 		rv = write(fds_fromtracee[1], &msg, sizeof(msg));
 		FORKEE_ASSERT(rv == sizeof(msg));
+		rv = read(fds_totracee[0], &msg, sizeof(msg));
+		FORKEE_ASSERT(rv == sizeof(msg));
+		rv = write(fds_fromtracee[1], &msg, sizeof(msg));
+		FORKEE_ASSERT(rv == sizeof(msg));
 
 		/* Wait for message from the parent */
 		rv = read(fds_totracee[0], &msg, sizeof(msg));
@@ -1053,7 +1057,11 @@ ATF_TC_BODY(attach5, tc)
 	ATF_REQUIRE(close(fds_totracee[0]) == 0);
 	ATF_REQUIRE(close(fds_fromtracee[1]) == 0);
 
-	printf("Wait for child to record its parent identifier (pid\n");
+	printf("Wait for child to record its parent identifier (pid)\n");
+	rv = read(fds_fromtracee[0], &msg, sizeof(msg));
+	FORKEE_ASSERT(rv == sizeof(msg));
+	rv = write(fds_totracee[1], &msg, sizeof(msg));
+	FORKEE_ASSERT(rv == sizeof(msg));
 	rv = read(fds_fromtracee[0], &msg, sizeof(msg));
 	FORKEE_ASSERT(rv == sizeof(msg));
 

Reply via email to