diff options
author | sin <sin@2f30.org> | 2019-08-22 15:09:29 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2019-08-22 17:21:29 +0100 |
commit | 58edea240e40eeb006923f012a6bb792fb8ef8a7 (patch) | |
tree | 8c3a04522acecc24a2cba5dc66af97389f678b9e /spawn.c | |
parent | 784551aa55ff996e103443d1bbe65684fd4d7463 (diff) | |
download | noice-58edea240e40eeb006923f012a6bb792fb8ef8a7.tar.gz |
Fix spawn*() so it can report errors to the caller
If nopen is not in PATH, noice will briefly print a warning about it
so the user knows.
Also, add NOPENCMD define in noiceconf.def.h to specify the default
plumber program.
Diffstat (limited to 'spawn.c')
-rw-r--r-- | spawn.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -9,7 +9,7 @@ #include "util.h" -void +int spawnvp(char *dir, char *file, char *argv[]) { pid_t pid; @@ -18,7 +18,7 @@ spawnvp(char *dir, char *file, char *argv[]) pid = fork(); switch (pid) { case -1: - err(1, "fork"); + return -1; case 0: if (dir != NULL) chdir(dir); @@ -27,10 +27,13 @@ spawnvp(char *dir, char *file, char *argv[]) default: while (waitpid(pid, &status, 0) == -1 && errno == EINTR) ; + if (WIFEXITED(status) && WEXITSTATUS(status) != 0) + return -1; } + return 0; } -void +int spawnlp(char *dir, char *file, char *argv0, ...) { char *argv[NR_ARGS]; @@ -43,5 +46,5 @@ spawnlp(char *dir, char *file, char *argv0, ...) ; argv[argc] = NULL; va_end(ap); - spawnvp(dir, file, argv); + return spawnvp(dir, file, argv); } |