Parent process does not catch all its child processes

I have the following problem:

I have basic (parent) procces that create other processes (childs) using the fork function. I am fond of childhood status to destroy zombies. When there is 1 child process, it is checked correctly, but when there are more processes (aprx. 30) created by the parent process, there is aprx. 4 zombies left = parent does not catch all children (return status / state = <defunct>).

The state of the child is fixed using

void selfkill(int status) {
    wait(&status);
}

signal(SIGCHLD, selfkill);

Thanks in advance.

+3
source share
1 answer

, waitpid() WNOHANG .

, , , , , . , sigaction() signal(), .

+4

Source: https://habr.com/ru/post/1775575/


All Articles