Fail spawn*() if chdir() fails - noice - small file browser (mirror / fork from 2f30.org)
(HTM) git clone git://git.codemadness.org/noice
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit a784c503368ba3d9f85b21647ae9fc08872a470c
(DIR) parent ab7d3fba38ec3bfe6ce6ba223106c05fdd00331d
(HTM) Author: sin <sin@2f30.org>
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(-)
---
(DIR) 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: