Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Send signal to perl script

by ladyscifi (Novice)
on Sep 28, 2012 at 20:54 UTC ( #996293=perlquestion: print w/replies, xml ) Need Help??
ladyscifi has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to send a signal to a perl script that is running in the background. When it is in the foreground, it handles SIGINT as expected. However, when it is in the background and I send the signal to the perl process, it ignores it.

As far as I can tell, the signals are being handled by the perl interpreter and not being passed on to the script. Is there a way to force perl to pass the signals on to the script?

Or am I just misunderstanding something? I'm running under Windows 7, fyi. below is the test signal handling code:

sub INT_handler { print("Don't Interrupt!\n"); } sub ABRT_handler { print("awwww!\n"); exit 0; } $SIG{'INT'} = 'INT_handler'; $SIG{'ABRT'} = 'ABRT_handler'; print "My pid is $$ \n"; for ($x = 0; $x < 100; $x++) { print("$x\n"); sleep 1; }

and what I'm running to try to signal it:

Perl\bin\perl.exe -e "$cnt = kill SIGINT, 14184; print $cnt"

Replies are listed 'Best First'.
Re: Send signal to perl script
by afoken (Monsignor) on Sep 29, 2012 at 07:03 UTC
Re: Send signal to perl script
by Anonymous Monk on Sep 29, 2012 at 00:25 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://996293]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2016-09-27 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (501 votes). Check out past polls.