Fail spawn*() if chdir() fails - noice - small file browser (mirror / fork from… | |
git clone git://git.codemadness.org/noice | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit a784c503368ba3d9f85b21647ae9fc08872a470c | |
parent ab7d3fba38ec3bfe6ce6ba223106c05fdd00331d | |
Author: sin <[email protected]> | |
Date: Thu, 22 Aug 2019 16:15:02 +0100 | |
Fail spawn*() if chdir() fails | |
Diffstat: | |
M spawn.c | 5 +++-- | |
1 file changed, 3 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/spawn.c b/spawn.c | |
@@ -5,6 +5,7 @@ | |
#include <err.h> | |
#include <errno.h> | |
#include <stdarg.h> | |
+#include <stdlib.h> | |
#include <unistd.h> | |
#include "util.h" | |
@@ -20,8 +21,8 @@ spawnvp(char *dir, char *file, char *argv[]) | |
case -1: | |
return -1; | |
case 0: | |
- if (dir != NULL) | |
- chdir(dir); | |
+ if (dir != NULL && chdir(dir) == -1) | |
+ exit(1); | |
execvp(file, argv); | |
_exit(1); | |
default: |