exit value not passed back

M

Mags

Dear All,

I have a strange problem I am calling a perl script from another perl script
using the system command.

The called perl script can exit with different values which I want to
capture in the calling script. This works fine unless the called script is
interrupted by ctrl-c (although I have accounted for this), instead of
getting -2 (as below) I get 1 returned??

Any advice much appreciated.

Maged



Here is sample of my code:

calling.pl
#######
eval { system ("called.pl"); };
$exit_val = $? >> 8;

called.pl
#######
$SIG{INT} = \&exit_gracefully;

main block ...
$exit_value = 0;

exit $exit_value;

sub exit_gracefully
{
$SIG{INT} = \&exit_gracefully;
print "Program interrupted .. \n";
exit (-2);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top