Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That pattern is wrong.

You call waitpid() directly, configured for timeout, and if it returns with error that the process is no longer available, then act upon it.



Two scenarios where this breaks:

* parent process is killed after it forks, but before it calls `waitpid`. Nothing even attempts to kill&wait for the child

* parent process is killed after it issues `waitpid` syscall. The child continues to happily execute while the parent is dead.


- waitpid returns after timeout, assume the process is dead, collect all zombie processes just in case.

- yeah this one is a bummer, write the child pids, collect them via a watchdog process




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: