mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Refactor sigchld_cb(), handle EINTR properly, restart waitpid()
The waitpid() function can return -1 due to EINTR (signal), so we should restart it to make sure we collect all zombies. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
6eccca31b9
commit
41a14391a2
1 file changed
+9
-5
@@ -403,13 +403,17 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reap all the children! */
|
/* Reap all the children! */
|
||||||
do {
|
while (1) {
|
||||||
pid = waitpid(-1, &status, WNOHANG);
|
pid = waitpid(-1, &status, WNOHANG);
|
||||||
if (pid > 0) {
|
if (pid <= 0) {
|
||||||
_d("Collected child %d", pid);
|
if (pid == -1 && errno == EINTR)
|
||||||
service_monitor(pid, status);
|
continue;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (pid > 0);
|
|
||||||
|
_d("Collected child %d", pid);
|
||||||
|
service_monitor(pid, status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in new issue
Block a user