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

Re: using fork in cgi & perl

> Well, the child is a zombie because the process which called fork
> did not wait() on the child process. This can be accomplished 
> asynchronously by handling the SIGCHLD signal. The following (somewhat
> modified to remove unecessary SysV stuff) example comes from the
> perlipc manpage:
>     sub REAPER { 
>         $waitedpid = wait;
>     }
>     $SIG{CHLD} = \&REAPER;
>     # now do something that forks...
> That code will make sure the child doesn't sit there as a zombie.
> As for why the result doesn't come up quickly I can't speculate 
> since I don't know what you're doing.

You might have to use the 'double fork()' trick. This creates two childs, 
where the second child becomes a child of init when the first child have 
exited and the parent wait()'s for the first child. See man perlfunc for 
more info. Sorry I don't give more info, just had a party and had had 
quite a lot of choice from delicious drinks :)


|     Maarten Boekhold, Faculty of Electrical Engineering TU Delft,   NL    |
|        M.Boekhold@et.tudelft.nl   boekhold@gopher.library.tudelft.nl      |

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com

Reply to: