Allow passing NULL as fds

This commit is contained in:
Nikita Ivanov 2022-05-23 23:49:57 +05:00
parent 8487750f1a
commit 1f460e2de1
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

12
utils.c
View File

@ -28,12 +28,14 @@ int spawn(char *args[], pid_t *cpid, int *exitcode, int *fds[2])
/* Child process */ /* Child process */
if (pid == 0) { if (pid == 0) {
while (*fds) { if (fds) {
if (dup2((*fds)[0], (*fds)[1]) == -1) { while (*fds) {
print_errorf("dup2() failed: %s", strerror(errno)); if (dup2((*fds)[0], (*fds)[1]) == -1) {
exit(EXIT_FAILURE); print_errorf("dup2() failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
fds = &fds[1];
} }
fds = &fds[1];
} }
execvp(args[0], args); execvp(args[0], args);