Re: Ending up with Zombie process




On Jan 30, 2006, at 5:08 AM, Eisenknapp, Josef wrote:

This works pretty fine, but when the process "write_to_fff.pl" terminates it becomes a ZOMBI.

Can anyone tell me how to avoid this?

Have you tried setting $SIG{CHLD} to 'IGNORE'? This typically sets up the system to reap your children automatically.


I tried it like in "Programming Perl" with:

my $kid;
do {
    $kid = waitpid(-1, &WNOHANG);
}until $kid == -1;

Then the Process terminated corretly, but my watch_callback() isn't called until "write_to_fff.pl" terminates.

Where did you do this? A good place for this cleanup code would be in the same block where you remove the dead watch.

Note that the little bit of code loops, so you're probably blocking the main loop waiting for the child to die, which would keep your watch handler from running. This leads me to believe you are doing the "wait for the child to die" code right after creating the pipe and installing the watch.


--
Examples really shouldn't include unexploded ordnance.
  -- Joe Smith, referring to an example program i wrote.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]