The problem with that solution is that if the fork fails,
block.exe will be executed, but the rest of the program won't. Also, system returns false if the command was
succesful, and any error status is in
$?, not
$!.
A better way would be:
my $pid = fork;
die "Fork failed: $!" unless defined $pid;
unless ($pid) {
system "C:\\block.exe";
die "Command failed with exit code ", $? >> 8 if $?;
exit;
}
print "processing second line...\n";
Or, if you don't want to handle failures of
block.exe in your program:
my $pid = fork;
die "Fork failed: $!" unless defined $pid;
unless ($pid) {
exec "C:\\block.exe";
die "exec failed: $!";
}
print "processing second line...\n";