Kill and Signals

I

Isidro Vila Verde

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
 
R

Roy Johnson

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

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.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top