Reap N-number of children per SIGCHLD
This commit is contained in:
parent
250e2ae24f
commit
5236c8d947
@ -706,9 +706,14 @@ void child_handler(int signum, siginfo_t *info, void *context)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
int status;
|
int status;
|
||||||
pid_t p = waitpid(-1, &status, WNOHANG);
|
pid_t p = waitpid(-1, &status, WNOHANG);
|
||||||
if(p == -1)
|
if(p == 0) // No more children to reap
|
||||||
|
{
|
||||||
|
return; // exits infinite while loop and child_handler() function
|
||||||
|
}
|
||||||
|
if(p == -1) // waitpid error
|
||||||
{
|
{
|
||||||
logerror("waitpid failed when handling child exit\n");
|
logerror("waitpid failed when handling child exit\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -743,6 +748,7 @@ void child_handler(int signum, siginfo_t *info, void *context)
|
|||||||
exit(adhocify_exit_code);
|
exit(adhocify_exit_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void set_signals()
|
void set_signals()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user