mags has asked for the wisdom of the Perl Monks concerning the following question:
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 shown below) I get 1 returned??
Any advice much appreciated.
Mags
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); }
Janitored by Arunbear - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: exit value not passed back
by PodMaster (Abbot) on Oct 06, 2004 at 10:38 UTC | |
by mags (Initiate) on Oct 06, 2004 at 13:33 UTC | |
by mags (Initiate) on Oct 08, 2004 at 12:04 UTC | |
|
Re: exit value not passed back
by muntfish (Chaplain) on Oct 06, 2004 at 08:33 UTC | |
by mags (Initiate) on Oct 06, 2004 at 09:56 UTC | |
by muntfish (Chaplain) on Oct 06, 2004 at 10:43 UTC |