Reputation: 2649
Does anybody know if a parent process can be notified that its child has finished without being blocked in the function wait(&state), and avoid that the child process become a zombie ?
wait(&state)
Upvotes: 0
Views: 54
Reputation: 1876
You probably want waitpid() instead of wait().
waitpid()
wait()
waitpid(0, NULL, WNOHANG)
This will return the pid of a dead child, or -1 immediately if there are none.
-1
Upvotes: 1