in reply to Spawned process exit status

Run and spawn exec a process in background mode. It only returns error codes for the exec return of the process -- not the result exit code. Use system() to get the exit code.
from the perldoc for system:
Because system() and backticks block SIGINT and SIGQUIT, killing the p +rogram they're running doesn't actually interrupt your program. @args = ("command", "arg1", "arg2"); system(@args) == 0 or die "system @args failed: $?" You can check all the failure possibilities by inspecting $? like this +: $exit_value = $? >> 8; $signal_num = $? & 127; $dumped_core = $? & 128;


-Waswas

Replies are listed 'Best First'.
Re^2: Spawned process exit status
by Anonymous Monk on Jun 22, 2005 at 19:45 UTC
    I made the changes and still I get the same. The script exits with an error code of 13 and $? reports back with 0.
    @args = ("/test/conf.pl", $cfg_test, $cfg_stat ); system(@args) == 0 or die "system @args failed: $?"; $exit_value = $? >> 8; $signal_num = $? & 127; $dumped_core = $? & 128; print "EXIT VALUE = $exit_value\n"; print "SIGNAL = $signal_num\n"; print "CORE = $dumped_core\n";
      That is because it never gets to your print "EXIT VALUE.. line when there is a non 0 exit on the conf.pl script. You explicitly tell it to die and spit out the unprocessed error held in $?.
      What do you think this line does? system(@args) == 0 or die "system @args failed: $?";


      -Waswas