Ruby as Windows Service

It's probably due to the fact that the Ruby interpreter
releases control to Windows when it waits for events. So you
have to have an event on a regular basis...

I've had the same problem with a TCPServer and came up with the
following hack:

         # The hack...

def self.trap(signal)
   Kernel::trap(signal){yield}
   Thread.new{loop{sleep 1}} # Stupid Windows...
end

Who is the self in this case? TCPServer?

         # Doesn't work with Kernel.trap .
         # Try it!

trap("INT"){puts "Terminating..." ; exit}

         # Just a demo...

require "socket"
puts "Hit ^C..."
TCPServer.new("0.0.0.0", 1234).accept

I tried serveral permutations I could think of but nothing worked :confused:
Will continue Monday...

I took it from a Module. Sorry. It has to be:

def trap(signal)
   Kernel::trap(signal){yield}
   Thread.new{loop{sleep 1}} # Stupid Windows...
end
  
gegroet,
Erik V.

···

On Fri, 13 Aug 2004 18:29:24 +0900, Mehr, Assaph (Assaph) wrote:

> def self.trap(signal)
> Kernel::trap(signal){yield}
> Thread.new{loop{sleep 1}} # Stupid Windows...
> end

Who is the self in this case? TCPServer?