aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2019-08-22 16:15:02 +0100
committersin <sin@2f30.org>2019-08-22 17:21:29 +0100
commita784c503368ba3d9f85b21647ae9fc08872a470c (patch)
tree6fe7e1a57700932a58dd6c224f004be72122a756
parentab7d3fba38ec3bfe6ce6ba223106c05fdd00331d (diff)
downloadnoice-a784c503368ba3d9f85b21647ae9fc08872a470c.tar.gz
Fail spawn*() if chdir() fails
-rw-r--r--spawn.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/spawn.c b/spawn.c
index 289fa12..1826910 100644
--- 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:
Un proyecto texto-plano.xyz