}
/*
- * Start a program, connecting its stdout to a pipe on our end and its stderr
- * to /dev/null, and storing the file descriptor to read from in the two
- * argument. Returns the PID of the new process. Errors are fatal.
+ * Start a program, connecting its output (stdout and stderr) to a pipe on our
+ * end, and storing the file descriptor to read from in the second argument.
+ * Returns the PID of the new process. Errors are fatal.
*/
static pid_t
test_start(const char *path, int *fd)
{
- int fds[2], errfd;
+ int fds[2];
pid_t child;
if (pipe(fds) == -1) {
sysdie("can't fork");
} else if (child == 0) {
/* In child. Set up our stdout and stderr. */
- errfd = open("/dev/null", O_WRONLY);
- if (errfd < 0)
- _exit(CHILDERR_STDERR);
- if (dup2(errfd, 2) == -1)
- _exit(CHILDERR_DUP);
close(fds[0]);
- if (dup2(fds[1], 1) == -1)
+ if (dup2(fds[1], STDOUT_FILENO) == -1)
+ _exit(CHILDERR_DUP);
+ if (dup2(fds[1], STDERR_FILENO) == -1)
_exit(CHILDERR_DUP);
/* Now, exec our process. */