diff options
author | sin <sin@2f30.org> | 2019-08-22 16:04:39 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2019-08-22 17:21:29 +0100 |
commit | ab7d3fba38ec3bfe6ce6ba223106c05fdd00331d (patch) | |
tree | f3d38b3766facfb07e754cbe49ab3e10ba652461 | |
parent | 19a73c3706a1b4fbfe8dfe03f570d4a6dc468186 (diff) | |
download | noice-ab7d3fba38ec3bfe6ce6ba223106c05fdd00331d.tar.gz |
Only check status field if waitpid() did not fail
-rw-r--r-- | spawn.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -13,7 +13,7 @@ int spawnvp(char *dir, char *file, char *argv[]) { pid_t pid; - int status; + int status, r; pid = fork(); switch (pid) { @@ -25,8 +25,10 @@ spawnvp(char *dir, char *file, char *argv[]) execvp(file, argv); _exit(1); default: - while (waitpid(pid, &status, 0) == -1 && errno == EINTR) - ; + while ((r = waitpid(pid, &status, 0)) == -1 && errno == EINTR) + continue; + if (r == -1) + return -1; if (WIFEXITED(status) && WEXITSTATUS(status) != 0) return -1; } |