in reply to rsh <defunct> processes appear when using fork and system calls

When Hell's Disk Is Full, Zombie Processes Shall Rise And Walk The Face Of The ...

You need to wait for your children from time to time, so they don't become zombies. Basically, keep a list of the PIDs of your children, spawn them all and then wait until they're all finished. Or do it with a signal handler. See perlipc for more information.

  • Comment on Re: rsh <defunct> processes appear when using fork and system calls

Replies are listed 'Best First'.
Re^2: rsh <defunct> processes appear when using fork and system calls
by whatwhat (Novice) on Aug 06, 2007 at 13:42 UTC
    But this is what I do with the 'waitpid' function. In the child signal handler:

    while(($dead_kid = waitpid(-1, WNOHANG)) > 0)

    This is what is recommended in O'Reily. If this is incorrect could you give a short example?

    Also, I want to emphasize that these defunct processes do not accumulate. That is they are removed after I delete the child pids in the script. This seems to indicate that they are becoming defunct when the child makes the system call to issue rsh (?). And after the child finishes, these 'rsh <defunct>' processes disappear. Strange, No?

    Thanks! Ed