Kill and Signals

Discussion in 'Perl' started by Isidro Vila Verde, Nov 16, 2003.

  1. Greetings,

    I need to handle signals to close some excel applications that my
    script open, when the script is killed by another process.

    My script is a little bit complex, but I wrote just two very small
    scripts to test the kill and signal.

    The scripts signal.pl is this one:
    map {$SIG{$_} = sub {my $n = shift; print "n=$n\n"}} keys %SIG;
    #just in case
    $SIG{INT} = sub {my $n = shift; print "n=$n\n"};
    print "pid = $$\n";
    sleep 1 while(1)

    And the second one (kill.pl) is just the following line:
    kill ($ARGV[0] => $ARGV[1]);

    What I call the second like this:
    >perl kill.pl INT pid_returned_from_first_script


    I expected the signal to be handled by fisrt script, but no matter
    what signal I sent, the first script never receives the signal. It
    just was killed without any signal handling.

    Does anyone know what I am doing wrong here?

    Isidro
    Isidro Vila Verde, Nov 16, 2003
    #1
    1. Advertising

  2. Isidro Vila Verde

    Roy Johnson Guest

    This newsgroup is defunct. You will reach more people on
    comp.lang.perl.misc.

    (Isidro Vila Verde) wrote in message news:<>...
    > I need to handle signals to close some excel applications that my
    > script open, when the script is killed by another process.


    Presumably, you're using ActivePerl.

    http://aspn.activestate.com/ASPN/docs/ActivePerl/faq/Windows/ActivePerl-Winfaq5.html#Signal_Handling
    Signals are unsupported by the Win32 API. The C Runtime provides crude
    support for signals, but there are serious caveats, such as inability
    to die() or exit() from a signal handler. Perl itself does not
    guarantee that signal handlers will not interrupt critical operations
    such as memory allocation, which means signal invocation may throw
    perl internals into disarray. For these reasons, signals are
    unsupported at this time.
    Roy Johnson, Nov 20, 2003
    #2
    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. Taras_96
    Replies:
    5
    Views:
    2,148
    Taras_96
    Apr 14, 2005
  2. Paul Sullivan

    Kill "Print" and "Save As" in intranet

    Paul Sullivan, Apr 22, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    361
    Patrice
    Apr 22, 2004
  3. anka
    Replies:
    3
    Views:
    35,684
  4. Murph
    Replies:
    9
    Views:
    461
    Mike Treseler
    Dec 7, 2006
  5. Goofy

    Kill And ASP.NET Session

    Goofy, Dec 15, 2006, in forum: ASP .Net
    Replies:
    13
    Views:
    12,715
    Mark Rae
    Dec 15, 2006
Loading...

Share This Page