noice

small file browser
git clone git://git.2f30.org/noice
Log | Files | Refs | README | LICENSE

commit e81a1c5362dc178e1c9006077f836d7ca5bfb577
parent 86fa68dc89e87d10748ceb642e4d766e9f2b749b
Author: sin <sin@2f30.org>
Date:   Sun,  4 Aug 2019 11:53:02 +0100

Die on fork() failure (thanks Evil_Bob)

Diffstat:
Mspawn.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/spawn.c b/spawn.c @@ -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) ;