Hi !

This patch fix an issue in the sync_pipe implementation. The problem is
the following : after the creation of a pipe we do not close any file
descriptor until the end of a test.

Let's imagine the following execution :

- Process A calls sync_pipe_create
- Process A do a fork (creation of process B)
- Process A calls sync_pipe_wait
---> Process A blocks on sync_pipe_wait
- Process B starts
- Process B exits because of an early error.

In this case, process A never exits. Since it has not closed its write
descriptor to the pipe, the pipe is not considered as broken, thus
process A is not notified its son is dead. Thus it will wait forever.

Regards.

R.

-- 
Renaud Lottiaux

Kerlabs
Bâtiment Germanium
80, avenue des buttes de Coësmes
35700 Rennes - France
Phone : (+33|0)6 80 89 19 34
Fax   : (+33|0)2 99 84 71 71
Email : [EMAIL PROTECTED]
Web   : http://www.kerlabs.com/
Index: cvs/lib/libtestsuite.c
===================================================================
--- cvs.orig/lib/libtestsuite.c	2008-06-02 15:37:10.000000000 +0200
+++ cvs/lib/libtestsuite.c	2008-06-02 15:43:13.000000000 +0200
@@ -83,13 +83,24 @@
 
 int sync_pipe_close(int fd[])
 {
-	return close (fd[0]) ||	close (fd[1]);
+	int r;
+
+	if (fd[0] != -1)
+		r = close (fd[0]);
+	if (fd[1] != -1)
+		r |= close (fd[1]);
+	return r;
 }
 
 int sync_pipe_wait(int fd[])
 {
 	char buf;
 	int r;
+
+	if (fd[1] != -1) {
+		close (fd[1]);
+		fd[1] = -1;
+	}
 	
 	r = read (fd[0], &buf, 1);
 	
@@ -103,6 +114,11 @@
 	char buf = 'A';
 	int r;
 
+	if (fd[0] != -1) {
+		close (fd[0]);
+		fd[0] = -1;
+	}
+
 	r = write (fd[1], &buf, 1);
 
 	if (r != 1)

Attachment: signature.asc
Description: This is a digitally signed message part.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to