piyush has asked for the wisdom of the Perl Monks concerning the following question:

- Does a parent need to wait on a child killed using SIGKILL?
- What would happen in case it does wait on such a child that has been killed using SIGKILL?
  • Comment on Does a parent need to wait on a child killed using SIGKILL?

Replies are listed 'Best First'.
Re: Does a parent need to wait on a child killed using SIGKILL?
by ikegami (Patriarch) on Sep 19, 2009 at 14:59 UTC

    Does a parent need to wait on a child killed using SIGKILL?

    Yes.
    It can wait because it wouldn't know not to.
    It must wait to free the resources the OS keeps in case the parent does wait.

    (If the parent doesn't wait, the resources will be freed when the parent exits.)

    What would happen in case it does wait on such a child that has been killed using SIGKILL?

    The zombie would be freed and $? would indicate the cause of death (just as if it had exist successfully, exited with an error or killed by another signal).

      Thanks :)
Re: Does a parent need to wait on a child killed using SIGKILL?
by ambrus (Abbot) on Sep 20, 2009 at 10:24 UTC

    In addition, you may want to wait to make sure the child is not running anymore, because the KILL might not kill it immediately.

      ok ..thanks for your help.
      I made the parent wait for the forked process, after the forked process had been killed. The parent was able to receive the PID of the process that had already been killed using: kill -9 <PID>.
      The fact that parent received the PID of the killed child indicates that the parent must actually wait for a killed process as well ..only then would the resources consumed by the child process would be freed (ex. Entry in the process table etc.)

      Please let me know in case I am missing anything here ....Thanks again!