PerlSearcher has asked for the wisdom of the Perl Monks concerning the following question:
I tried using signals on Windows XP. I was thinking to use signal as a way for IPC to have the target process do something upon a signal and keep alive. But I found that whenever a process receives a signal from another process, it exits right away without **doing anything (i.e., it is not processing the code in the handler)** and **not keeping alive**
I verified that the process only reacts on the signals having been associated with handlers.
My questions:
1. How can I make the code in the handler to be executed?
2. Is there a way to keep the process alive after receiving the signal?
Here is the example, run this script in one command line window first.
Then, run this in another command line window:#!c:\perl\bin\perl.exe #Assign signal handlers $SIG{'NUM12'} = 'handler'; $SIG{'CHLD'} = 'handler'; print "List current SIG handlers...\n"; while ( my ($key, $value) = each(%SIG) ) { print "$key => $value\n" if ($value ne ''); } print "My PID is $$. I go sleep and wait for signals and ...\n"; while(1) { sleep; } sub handler{ local ($sig) = @_; # Problem: This line never printed. print "I am doing something for SIG $sig....\n"; }
What happened was--whenever the first process received the signal, it exit right away without printing any message from the handler.perl -e "kill CLD, <the PID displayed in the first window>"
Any idea?
Thanks
PerlSearcher
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Signals on Windows XP
by Corion (Patriarch) on Jul 27, 2007 at 22:19 UTC | |
|
Re: Using Signals on Windows XP
by ikegami (Patriarch) on Jul 28, 2007 at 05:58 UTC | |
|
Re: Using Signals on Windows XP
by BrowserUk (Patriarch) on Jul 28, 2007 at 11:03 UTC |