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

Re: using fork in cgi & perl



Hi...
Thanks for the help.

I've tried different combinations of using wait. And they all work fine
for making the child exit. But now the problem is that the parent for some
reason is not going to completion. It seems the very first statement in
the parent (after the child) executes, but the rest doesn't :(

Basically I have:

# cgi initialization ...
...
# output a list of users to a file

unless (fork) {

    # output html code
}
else {
    wait;
    # debug
    system ("cp /tmp/email.list /tmp/email.list2");

    while (<list of users>) {
        # read in file above and send mail to each recipient
    }

    # debug
    system ("cp /tmp/email.list /tmp/email.list3");
}

That's pretty much what I have. I also put in a "close STDOUT" to force
the html output to go out. But what's happening now is that the parent
process is not doing its entire task. For debug, I put in some file copy
statements as seen above. The first cp goes thru, but I never get an
email.list3 file...

? help! ;)

Ricardo

On Fri, 3 Jan 1997, Jens B. Jorgensen wrote:

> 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.
> 
> -- 
> Jens B. Jorgensen
> jjorgens@bdsinc.com
> 


--
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: