in reply to How to get system -function negative return value?
Using these two test progs:
process.pl
#!perl use strict; use warnings; my $exitCode = shift; print "will exit with $exitCode\n"; exit($exitCode);
shell.pl
#!perl use strict; use warnings; sub run_proc { my $code = shift; print "now running with $code\n"; my $status = system("process.pl $code"); my $exit_value = $status >> 8; my $signal_num = $status & 127; my $dumped_core = $status & 128; print <<"END_OF_STATUS"; exit_value: $exit_value signal_num: $signal_num dumped_core: $dumped_core END_OF_STATUS } run_proc(123); run_proc(-1); run_proc(255); run_proc(-5); run_proc(251);
I obtain these results with ActivePerl 5.8.3.809 on Windows 2000 (binary release):
now running with 123 will exit with 123 exit_value: 123 signal_num: 0 dumped_core: 0 now running with -1 will exit with -1 Can't spawn "cmd.exe": No such file or directory at c:\Exit value\shel +l.pl line 10. exit_value: 255 signal_num: 0 dumped_core: 0 now running with 255 will exit with 255 exit_value: 255 signal_num: 0 dumped_core: 0 now running with -5 will exit with -5 exit_value: 251 signal_num: 0 dumped_core: 0 now running with 251 will exit with 251 exit_value: 251 signal_num: 0 dumped_core: 0
The '-1' return code seems to have a special meaning. Sorry, I couldn't see why looking at perl's source code... You should give your perl -V results.
Anyway, I could get negative return code...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to get system -function negative return value?
by Anonymous Monk on May 27, 2004 at 10:52 UTC |