# Signal handler problem

**URL:** <https://www.ruby-forum.com/t/signal-handler-problem/107999>\
**Category:** Ruby\
**Created:** [June 28, 2007, 8:52am UTC](https://www.ruby-forum.com/t/signal-handler-problem/107999 "2007-06-28T08:52:42Z")\
**Posts on this page:** 1\
**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 28, 2007, 8:52am UTC](https://www.ruby-forum.com/t/signal-handler-problem/107999/1 "2007-06-28T08:52:42Z")

</div>

Consider the snippet -

#------------------------------  
require ‘socket’  
require ‘thread’

t = Thread.new do  
sock = UDPSocket.new  
sock.bind(“127.0.0.1”, 9000)  
2.times do  
IO.select([sock])  
msg = sock.recvfrom\_nonblock(1000)  
puts msg  
end  
end

puts “installing signal handler”

trap(“INT”) { puts “control-c received” } # do nothing, just print  
t.join

# ---------------------------------

One user thread blocks on IO and the main thread joins for this thread  
but  
after installing a signal handler.  
I would expect the control-c to be trapped by this but that does not  
happen  
until the thread blocked for IO is unblocked by a network message.

My ruby is “ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]”

Am I missing something here?

TIA

- Nasir
