From 0afdd64db5164c2090f2f0f4ce04bd11c802f782 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Mon, 5 Feb 2018 15:43:06 -0800 Subject: [PATCH] t-runner: refactor logic for output hiding --- tools/test-runner.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/test-runner.c b/tools/test-runner.c index 0678b5d5..e41aae3a 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -407,18 +407,6 @@ static void start_qemu(void) execve(argv[0], argv, qemu_envp); } -static void set_output_visibility(void) -{ - int fd; - - fd = open("/dev/null", O_WRONLY); - - dup2(fd, 1); - dup2(fd, 2); - - close(fd); -} - static pid_t execute_program(char *argv[], bool wait, bool verbose) { int status; @@ -439,8 +427,14 @@ static pid_t execute_program(char *argv[], bool wait, bool verbose) } if (child_pid == 0) { - if (!verbose) - set_output_visibility(); + if (!verbose) { + int fd = open("/dev/null", O_WRONLY); + + dup2(fd, 1); + dup2(fd, 2); + + close(fd); + } execvp(argv[0], argv);