# Signal handling problem in ruby

**URL:** <https://www.ruby-forum.com/t/signal-handling-problem-in-ruby/107617>\
**Category:** Ruby\
**Created:** [June 24, 2007, 4:33am UTC](https://www.ruby-forum.com/t/signal-handling-problem-in-ruby/107617 "2007-06-24T04:33:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasir\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/838e76/32.png) [@Nasir\_K](https://www.ruby-forum.com/u/Nasir_K)\
**Post date:** [June 24, 2007, 4:33am UTC](https://www.ruby-forum.com/t/signal-handling-problem-in-ruby/107617/1 "2007-06-24T04:33:20Z")

</div>

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/220937](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/220937)

I presume I am running into similar problem but this time with ruby  
1.8.6(2007-03-13 patchlevel 0) [i386-mswin32] (under windows).  
Basically my program runs and spawns several threads, some of which  
block on  
network IO but the main thread after doing all initialization etc  
installs a  
signal handler by trap(“INT”) { s.stop } where stop() is a method  
call to  
stop processing.

The ^c signal is not delivered to the program until I send a network  
message  
(unblocks the different thread waiting for IO).

Is this issue seen by others on 1.8.6? Any pointers are appreciated.

TIA

- nasir

---

<div class="post-metadata">

**Author:** ![Nasir\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/838e76/32.png) [@Nasir\_K](https://www.ruby-forum.com/u/Nasir_K)\
**Post date:** [June 24, 2007, 5:48pm UTC](https://www.ruby-forum.com/t/signal-handling-problem-in-ruby/107617/2 "2007-06-24T17:48:20Z")

</div>

Hi Nasir,

Make sure you trap the signal in the thread you put your main sleep,  
otherwise maybe the thread finishes and the trap goes nirvana…

Regards  
Florian
