mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07: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:
@@ -403,13 +403,17 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
|
||||
}
|
||||
|
||||
/* Reap all the children! */
|
||||
do {
|
||||
while (1) {
|
||||
pid = waitpid(-1, &status, WNOHANG);
|
||||
if (pid > 0) {
|
||||
_d("Collected child %d", pid);
|
||||
service_monitor(pid, status);
|
||||
if (pid <= 0) {
|
||||
if (pid == -1 && errno == EINTR)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
} while (pid > 0);
|
||||
|
||||
_d("Collected child %d", pid);
|
||||
service_monitor(pid, status);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user