exit value not passed back

Discussion in 'Perl Misc' started by Mags, Oct 5, 2004.

  1. Mags

    Mags Guest

    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);
    }
     
    Mags, Oct 5, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dee
    Replies:
    9
    Views:
    541
    Joseph Byrns
    Apr 15, 2005
  2. Anand
    Replies:
    2
    Views:
    938
    Anand
    Sep 11, 2003
  3. Yujo
    Replies:
    2
    Views:
    441
    Gabriel Genellina
    Apr 10, 2007
  4. DC
    Replies:
    0
    Views:
    329
  5. Harlin Seritt

    Sys.exit() does not fully exit

    Harlin Seritt, Feb 17, 2008, in forum: Python
    Replies:
    3
    Views:
    299
    Christian Heimes
    Feb 17, 2008
Loading...

Share This Page