# TCPSocket.accept blocks signals on win32?

**URL:** <https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745>\
**Category:** Ruby\
**Created:** [March 21, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745 "2006-03-21T17:19:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/1 "2006-03-21T17:19:01Z")

</div>

On Windows XP, ruby 1.8.4.

I have this

`
LISTENER = TCPServer.new( HOST, PORT )
s = LISTENER.accept
host_info = l_session.peeraddr
name = "#{host_info[2]}@#{host_info[3]}"
puts( "new connection from #{name}", 'debug' )
s.close
exit 0
`

Running the above script will block on the accept. Good. But I can’t  
kill the process with CTRL-C, while it is accepting. Is this a win32  
caveat? I tried trapping the INT signal, but it seems that the signal  
does not even get sent, as my trap-block never gets called.

~S

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 5:50pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/2 "2006-03-21T17:50:21Z")

</div>

It is a mystery to me too. Sometimes I can break out of Ruby code  
using Ctrl-C under Windows. Other times I need to use Ctrl-Break.

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 7:13pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/3 "2006-03-21T19:13:54Z")

</div>

Mark V. wrote:

> It is a mystery to me too. Sometimes I can break out of Ruby code  
> using Ctrl-C under Windows. Other times I need to use Ctrl-Break.

What signal does CTRL-Break send? I can’t seem to trap it with ‘KILL’,  
‘INT’, or ‘TERM’.

~S

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 6:49pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/4 "2006-03-21T18:49:29Z")

</div>

Mark V. wrote:

> It is a mystery to me too. Sometimes I can break out of Ruby code  
> using Ctrl-C under Windows. Other times I need to use Ctrl-Break.

I didn’t know about ctrl-break. (I am not a windows guy). But if  
ctrl-break works, that is good enough.

~S

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/5 "2006-03-21T19:43:41Z")

</div>

Shea M. wrote:

> Mark V. wrote:
> 
> > It is a mystery to me too. Sometimes I can break out of Ruby code  
> > using Ctrl-C under Windows. Other times I need to use Ctrl-Break.
> 
> What signal does CTRL-Break send? I can’t seem to trap it with ‘KILL’,  
> ‘INT’, or ‘TERM’.

If windows is like unix/linux, you can’t trap KILL, anyway. So maybe  
Ctrl-Break is KILL.

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 21, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/6 "2006-03-21T19:23:59Z")

</div>

Shea M. wrote:

> Mark V. wrote:
> 
> > It is a mystery to me too. Sometimes I can break out of Ruby code  
> > using Ctrl-C under Windows. Other times I need to use Ctrl-Break.
> 
> What signal does CTRL-Break send? I can’t seem to trap it with ‘KILL’,  
> ‘INT’, or ‘TERM’.

Further:

Signal.list.each\_key { | sig |  
Kernel.trap( sig ) {  
puts “caught #{sig}”  
exit 1  
}  
}

sleep 30

exit 0

running this, then doing a Ctrl-Break, does not output anything, i.e.,  
the signal is not trapped. Maybe it is not possible to trap break.

~S

---

<div class="post-metadata">

**Author:** ![Shea\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecccb3/32.png) [@Shea\_M](https://www.ruby-forum.com/u/Shea_M)\
**Post date:** [March 22, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/tcpsocket-accept-blocks-signals-on-win32/84745/7 "2006-03-22T17:24:07Z")

</div>

Joel VanderWerf wrote:

> Shea M. wrote:
> 
> > Mark V. wrote:
> > 
> > > It is a mystery to me too. Sometimes I can break out of Ruby code  
> > > using Ctrl-C under Windows. Other times I need to use Ctrl-Break.  
> > > What signal does CTRL-Break send? I can’t seem to trap it with ‘KILL’,  
> > > ‘INT’, or ‘TERM’.
> 
> If windows is like unix/linux, you can’t trap KILL, anyway. So maybe  
> Ctrl-Break is KILL.

Aah, yes.
