diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/evanix.c | 6 | ||||
-rw-r--r-- | src/jobs.c | 4 | ||||
-rw-r--r-- | src/util.c | 14 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/evanix.c b/src/evanix.c index cd35782..b801e73 100644 --- a/src/evanix.c +++ b/src/evanix.c @@ -17,11 +17,11 @@ static const char usage[] = " -s, --system System to build for.\n" " -m, --max-build Max number of builds.\n" " -p, --pipelined <bool> Use evanix build pipeline.\n" - " -c, --close-stderr-exec <bool> Close stderr on exec.\n" + " -c, --close-unused-fd <bool> Close stderr on exec.\n" "\n"; struct evanix_opts_t evanix_opts = { - .close_stderr_exec = true, + .close_unused_fd = true, .isflake = false, .ispipelined = true, .isdryrun = false, @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - evanix_opts.close_stderr_exec = ret; + evanix_opts.close_unused_fd = ret; break; default: fprintf(stderr, @@ -257,7 +257,7 @@ int job_read(FILE *stream, struct job **job) temp = cJSON_GetObjectItemCaseSensitive(root, "error"); if (cJSON_IsString(temp)) { - if (evanix_opts.close_stderr_exec) + if (evanix_opts.close_unused_fd) puts(temp->valuestring); ret = JOB_READ_EVAL_ERR; goto out_free; @@ -463,7 +463,7 @@ int jobs_init(FILE **stream, char *expr) args[argindex++] = NULL; /* the package is wrapProgram-ed with nix-eval-jobs */ - ret = vpopen(stream, XSTR(NIX_EVAL_JOBS_PATH), args); + ret = vpopen(stream, XSTR(NIX_EVAL_JOBS_PATH), args, VPOPEN_STDOUT); return ret; } @@ -42,7 +42,7 @@ out_free_line: return ret; } -int vpopen(FILE **stream, const char *file, char *const argv[]) +int vpopen(FILE **stream, const char *file, char *const argv[], vpopen_t type) { int fd[2], ret; int nullfd = -1; @@ -72,19 +72,25 @@ int vpopen(FILE **stream, const char *file, char *const argv[]) } close(fd[0]); - ret = dup2(fd[1], STDOUT_FILENO); + if (type == VPOPEN_STDOUT) + ret = dup2(fd[1], STDOUT_FILENO); + else + ret = dup2(fd[1], STDERR_FILENO); if (ret < 0) { print_err("%s", strerror(errno)); goto out_close_fd_1; } - if (evanix_opts.close_stderr_exec) { + if (evanix_opts.close_unused_fd) { nullfd = open("/dev/null", O_WRONLY); if (nullfd < 0) { print_err("%s", strerror(errno)); goto out_close_fd_1; } - ret = dup2(nullfd, STDERR_FILENO); + if (type == VPOPEN_STDOUT) + ret = dup2(nullfd, STDERR_FILENO); + else + ret = dup2(nullfd, STDOUT_FILENO); if (ret < 0) { print_err("%s", strerror(errno)); goto out_close_nullfd; |