From 1f460e2de1a2d2bdfaf0f7de19e27654ffa15662 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Mon, 23 May 2022 23:49:57 +0500 Subject: [PATCH] Allow passing NULL as fds --- utils.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/utils.c b/utils.c index a9c7d6d..d2a8f7c 100644 --- a/utils.c +++ b/utils.c @@ -28,12 +28,14 @@ int spawn(char *args[], pid_t *cpid, int *exitcode, int *fds[2]) /* Child process */ if (pid == 0) { - while (*fds) { - if (dup2((*fds)[0], (*fds)[1]) == -1) { - print_errorf("dup2() failed: %s", strerror(errno)); - exit(EXIT_FAILURE); + if (fds) { + while (*fds) { + if (dup2((*fds)[0], (*fds)[1]) == -1) { + print_errorf("dup2() failed: %s", strerror(errno)); + exit(EXIT_FAILURE); + } + fds = &fds[1]; } - fds = &fds[1]; } execvp(args[0], args);