Forum: Ruby How can I use Trapping signals in Windows?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jarod Z. (Guest)
on 2008-12-10 10:41
(Received via mailing list)
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 Z.
This topic is locked and can not be replied to.