On Friday, April 26, 2002, at 09:01 , Alex Read wrote:
> Hello,
>
> OK, I have a nice a simple test case, but I just can't get it to do what
> I want it to.
[..]
>
> Alex.
>
>
> #!/usr/bin/perl
> use strict;
>
> my $pid = fork && exit; #$pid should return 0 if fork is
> successful.
>
> if ($pid == 0 ) {
> exec "sleep 100" or die "Cannot sleep: $!" ;
> }
> print "Content-type: text/html\n\n<html>";
> print "\nhi\n\n</html>\n\n";
perldoc -f fork
the parent will get the PID of the child,
and the child will get the '0' - hence
the line
my $pid = fork && exit;
will exit the parent process......
so traditionally I would have coded that as
my $pid = fork;
if ( $pid == 0 ) {
# the child side process
# where you deal with the forked stuff.
} else {
# the parent side of the process
# where you send back the webPage
}
and deal with who actually controls things like STDIN
and STDERR and the like...
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]