How to trap signal on ruby running on windows?
I want to send signal/message from c++ application to ruby script
How to trap signal on ruby running on windows?
I want to send signal/message from c++ application to ruby script
Look into the Signal Module. The documentation has a pretty good example at the very top.
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;}