How can I use Trapping signals in Windows?

J

Jarod Zhu

Hi, all

I am using ruby 1.8.6-26 in Windows and I want to trapping
siganls in a process, like
******************************************************************
Deamon Process:

loop do
Signal.trap("USR1") do
puts "catch signal"
do some work....
end
sleep 1
end
*******************************************************************
But when running the code, it reported the error:
--in `trap': unsupported signal SIGUSR1 (ArgumentError)

It seems some signals aren't supported by windows.
Then I replaced "USR1" to "EXIT", the code passed.
But when I used "Process.kill("EXIT", pid)" in irb, it repors error:
--ArgumentError: unsupported name `SIGEXIT'
Then I used "Process.kill(0, pid)" instead, it retruns 1 without
"catch signal"
Then I entered "Ctrl-C", "catch signal" appeared.

So how can I use Signal.trap sucessfully in windows ?
If the signal delivery may not be reliable, which mechanism can I use
to control the process?

Thanks
Jarod Zhu
 

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,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top