[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

TCPSocket.accept blocks signals on win32?

Shea Martin

3/21/2006 4:15:00 PM

On Windows XP, ruby 1.8.4.

I have this

<code>
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
</code>

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
6 Answers

Mark Volkmann

3/21/2006 4:50:00 PM

0

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.

On 3/21/06, Shea Martin <null@void.0> wrote:
> On Windows XP, ruby 1.8.4.
>
> I have this
>
> <code>
> 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
> </code>
>
> 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
>
>


--
R. Mark Volkmann
Object Computing, Inc.


Shea Martin

3/21/2006 5:47:00 PM

0

Mark Volkmann 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

Shea Martin

3/21/2006 6:09:00 PM

0

Mark Volkmann 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

Shea Martin

3/21/2006 6:22:00 PM

0

Shea Martin wrote:
> Mark Volkmann 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

Joel VanderWerf

3/21/2006 6:44:00 PM

0

Shea Martin wrote:
> Mark Volkmann 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.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Shea Martin

3/22/2006 4:20:00 PM

0

Joel VanderWerf wrote:
> Shea Martin wrote:
>> Mark Volkmann 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.