mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-05-28 04:02:31 -04:00
tests: tests stderr redirected to the output
This commit is contained in:
parent
3a9e5d3cd5
commit
3f3d78c19b
1 changed files with 7 additions and 10 deletions
|
|
@ -384,14 +384,14 @@ skip_whitespace(const char *p)
|
|||
}
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
|
|
@ -406,13 +406,10 @@ test_start(const char *path, int *fd)
|
|||
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. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue