use strict;
use warnings;
print "FIRST\n";
fork();
print "SECOND\n";
Outputs:
FIRST
SECOND
SECOND
It would therefor appear that it DOES execute that command twice. If you think it does not, please supply what you are using as evidence so that we might see what you are doing differently.
| [reply] [d/l] [select] |
I agree, your example is correct, that's how fork works.
My demo above is what i'm doing. If I run that from the command line, it executes twice, yes. But if apache executes it, some_cmd is only executed once. I expect it has something to do with my close STDOUT line, which in a normal script apparently is a synonym for exit() (when run by apache). So, really, I don't understand why it ran some_cmd once, when it should have been either none or twice, I could rationally explain either of those outcomes
It's not what you look like, when you're doin' what you’re doin'.
It's what you’re doin' when you’re doin' what you look like you’re doin'! - Charles Wright & the Watts 103rd Street Rhythm Band, Express yourself
| [reply] [d/l] [select] |
my $child_id = fork;
unless (defined $child_id) {
die "Can't fork!";
}
if ($child_id) {
#in parent...
}
else {
#in child
}
| [reply] [d/l] |