diff --git a/runner/runner.cpp b/runner/runner.cpp index 4b0f8da..009ff54 100644 --- a/runner/runner.cpp +++ b/runner/runner.cpp @@ -23,7 +23,8 @@ int execute_cmd( } int pipefd[2]; - if (output && pipe(pipefd) == -1) { + bool use_pipe = output && !interactive; + if (use_pipe && pipe(pipefd) == -1) { perror("pipe"); return -1; } @@ -45,12 +46,12 @@ int execute_cmd( for (const auto& kv : env) { setenv(kv.first.c_str(), kv.second.c_str(), 1); } - if (output) { + if (use_pipe) { close(pipefd[0]); dup2(pipefd[1], STDOUT_FILENO); dup2(pipefd[1], STDERR_FILENO); close(pipefd[1]); - } else if (silent) { + } else if (silent && !interactive) { int devnull = open("/dev/null", O_WRONLY); dup2(devnull, STDOUT_FILENO); dup2(devnull, STDERR_FILENO); @@ -71,7 +72,7 @@ int execute_cmd( exit(-1); } else { // Parent process - if (output) { + if (use_pipe) { close(pipefd[1]); std::ostringstream oss; char buf[4096];