Introduction
Introduction Statistics Contact Development Disclaimer Help
Die on fork() failure (thanks Evil_Bob) - noice - small file browser (mirror / …
git clone git://git.codemadness.org/noice
Log
Files
Refs
README
LICENSE
---
commit e81a1c5362dc178e1c9006077f836d7ca5bfb577
parent 86fa68dc89e87d10748ceb642e4d766e9f2b749b
Author: sin <[email protected]>
Date: Sun, 4 Aug 2019 11:53:02 +0100
Die on fork() failure (thanks Evil_Bob)
Diffstat:
M spawn.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)
;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.