in reply to Re: quoted execution not working
in thread quoted execution not working
There are two things wrong with that. If the fork fails, $pid is undef, but will still compare true to 0. Second, if it fails, the error is in $!, not $pid. So you actually want:my $pid=fork(); if ( $pid == 0 } { : child process goes here } elsif { $pid > 0 ) { : parent process wait(); # Wait for the child to exit } else { # WOAH! We should never get here! die "fork returned $pid"; }
my $pid=fork(); if (not defined $pid) { die "fork failed: $!\n"; } elsif ( $pid == 0 } { : child process goes here } else { : parent process wait(); # Wait for the child to exit }
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: quoted execution not working
by blue_cowdawg (Monsignor) on Jul 28, 2004 at 00:10 UTC |