svn commit: samba r19436 - in branches/SAMBA_4_0/source/torture: .

tridge at samba.org tridge at samba.org
Sat Oct 21 06:56:52 GMT 2006


Author: tridge
Date: 2006-10-21 06:56:51 +0000 (Sat, 21 Oct 2006)
New Revision: 19436

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19436

Log:

fixed stderr in piped_child() as well

Modified:
   branches/SAMBA_4_0/source/torture/subunit.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/subunit.c
===================================================================
--- branches/SAMBA_4_0/source/torture/subunit.c	2006-10-21 06:44:36 UTC (rev 19435)
+++ branches/SAMBA_4_0/source/torture/subunit.c	2006-10-21 06:56:51 UTC (rev 19436)
@@ -184,6 +184,7 @@
 	int status;
 	char buffer[4096];
 	size_t offset = 0;
+	
 
 	command[0] = talloc_strdup(context, suite->path);
 	command[1] = NULL;
@@ -192,8 +193,30 @@
 	if (pid == -1)
 		return false;
 
-	while ((size = read(fd_out, buffer+offset, sizeof(buffer-offset) > 0))) {
+	while (1) {
+		fd_set fds;
 		char *eol;
+
+		FD_ZERO(&fds);
+
+		FD_SET(fd_out, &fds);
+		FD_SET(fd_err, &fds);
+
+		if (select(MAX(fd_out,fd_err)+1, &fds, NULL, NULL, NULL) <= 0) break;
+
+		if (FD_ISSET(fd_err, &fds)) {
+			size = read(fd_err, buffer+offset, sizeof(buffer) - (offset+1));
+			if (size <= 0) break;
+			write(2, buffer+offset, size);
+			continue;
+		}
+
+		if (!FD_ISSET(fd_out, &fds)) continue;
+
+		size = read(fd_out, buffer+offset, sizeof(buffer) - (offset+1));
+
+		if (size <= 0) break;
+
 		buffer[offset+size] = '\0';
 
 		write(1, buffer+offset, size);
@@ -247,7 +270,7 @@
 				}
 			}
 		}
-
+		
 		offset += size-(p-buffer);
 		memcpy(buffer, p, offset);
 	}



More information about the samba-cvs mailing list