diff options
author | sin <sin@2f30.org> | 2019-08-04 11:53:02 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2019-08-04 11:53:20 +0100 |
commit | e81a1c5362dc178e1c9006077f836d7ca5bfb577 (patch) | |
tree | 8150df5c4796e3dee53d3c740ce719e33fad0de2 | |
parent | 86fa68dc89e87d10748ceb642e4d766e9f2b749b (diff) | |
download | noice-e81a1c5362dc178e1c9006077f836d7ca5bfb577.tar.gz |
Die on fork() failure (thanks Evil_Bob)
-rw-r--r-- | spawn.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2,6 +2,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <err.h> #include <stdarg.h> #include <unistd.h> @@ -14,12 +15,15 @@ spawnvp(char *dir, char *file, char *argv[]) int status; pid = fork(); - if (pid == 0) { + switch (pid) { + case -1: + err(1, "fork"); + case 0: if (dir != NULL) chdir(dir); execvp(file, argv); _exit(1); - } else { + default: /* Ignore interruptions */ while (waitpid(pid, &status, 0) == -1) ; |