How to Capture Signal on Ruby Running on Windows
3 answers
It depends on the signal. If you want to catch ctrl-C this works on Windows. Many signals (sigup1, sigusr1, etc.) don't really work on Windows (at least not for me). Here's how to catch ctrl-C. In this example, I just type a message and exit the application. You can pass any proc object to the signal manager - be sure to pay attention to the scope if you read / edit variables inside the proc:
trap("INT") { puts "\nExiting"; exit;}
+2
a source to share