summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-21 06:56:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:31 -0500
commit1427d5012a353bd6d3a5448089a7b195ff391c39 (patch)
treed774c54cbc5f61626b08f8829f6f5ca09aa09510
parentacadb12c26165825d357499e946875fc33f62344 (diff)
downloadsamba-1427d5012a353bd6d3a5448089a7b195ff391c39.tar.gz
samba-1427d5012a353bd6d3a5448089a7b195ff391c39.tar.bz2
samba-1427d5012a353bd6d3a5448089a7b195ff391c39.zip
r19436: fixed stderr in piped_child() as well
(This used to be commit db000261f4fe22f7d1ea3dab53c2e214dcf08bfb)
-rw-r--r--source4/torture/subunit.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source4/torture/subunit.c b/source4/torture/subunit.c
index e417b45306..ce9bc66b9d 100644
--- a/source4/torture/subunit.c
+++ b/source4/torture/subunit.c
@@ -184,6 +184,7 @@ bool torture_subunit_run_suite(struct torture_context *context,
int status;
char buffer[4096];
size_t offset = 0;
+
command[0] = talloc_strdup(context, suite->path);
command[1] = NULL;
@@ -192,8 +193,30 @@ bool torture_subunit_run_suite(struct torture_context *context,
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 @@ bool torture_subunit_run_suite(struct torture_context *context,
}
}
}
-
+
offset += size-(p-buffer);
memcpy(buffer, p, offset);
}