tags:

views:

572

answers:

3

How to trap signal on ruby running on windows?

I want to send signal/message from c++ application to ruby script

+2  A: 

Look into the Signal Module. The documentation has a pretty good example at the very top.

zenazn
A: 

It depends on the signal. If you want to trap ctrl-C, that works in Windows. Many signals (sigup1, sigusr1, etc) don't really work right in Windows (at least not for me). Here's how to trap ctrl-C. In this example, I'm just printing a message and then exiting the application. You could pass any proc object to the signal manager -- be sure you pay attention to scope, if you read/edit variables inside the proc:

trap("INT") { puts "\nExiting"; exit;}
science
A: 

Signal.list tells you which ones are supported on your system

rogerdpack