in reply to Re: Reaping Zombies (dont wanna wait)
in thread Reaping Zombies (dont wanna wait)

Dear All,

Thanks for your input, understanding forks better, I realised that since I didnt want control of the child, i used 'exec()':

FORK: { $child = fork; if (defined $child) { if($child == 0){ exec("/usr/local/bin/monster", "-i$id", "$filePath$file") or die "couldn't exec monster: $!"; } }elsif ($! == EAGAIN) { sleep 5; redo FORK; }else { die "Can't fork: $!\n"; } }

However, now the child refuses to exit, which is strange. It wont even 'die' and print the error message if any.

I tried this very same thing with pemungkah's suggestion, and again it happened, the child won't exit.

Repeated requests creates new children, but they are all hanging there...

Anyone?

Sam

Replies are listed 'Best First'.
Re: Re: Re: Reaping Zombies (dont wanna wait)
by seaver (Pilgrim) on Jun 11, 2003 at 18:55 UTC
    woops, forgot to sign in. This 'A.M.' is actually seaver.
Re: Re: Re: Reaping Zombies (dont wanna wait)
by pemungkah (Priest) on Jun 24, 2003 at 21:19 UTC
    Try isolating the "must fork" code; trying to get the redo sorted out was driving me nuts:
    sub insistent_fork { my $pid = undef; FORK: { if (defined ($pid = fork())) { return $pid; } elsif ($! =~ /No more process/) { sleep 5; redo FORK; } else { die "Can't fork: $!\n"; } } }
    You can pair this with the original code I posted, substituting insistent_fork for fork. (Works on OS X.)