aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2019-08-22 16:04:39 +0100
committersin <sin@2f30.org>2019-08-22 17:21:29 +0100
commitab7d3fba38ec3bfe6ce6ba223106c05fdd00331d (patch)
treef3d38b3766facfb07e754cbe49ab3e10ba652461
parent19a73c3706a1b4fbfe8dfe03f570d4a6dc468186 (diff)
downloadnoice-ab7d3fba38ec3bfe6ce6ba223106c05fdd00331d.tar.gz
Only check status field if waitpid() did not fail
-rw-r--r--spawn.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/spawn.c b/spawn.c
index 98fd5e2..289fa12 100644
--- a/spawn.c
+++ b/spawn.c
@@ -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;
}
Un proyecto texto-plano.xyz