Has anyone else tried adding UNIX datagram sockets to Ruby?  I can't quite see 
the use of them myself, but they're a staple part of controlling User-Mode 
Linux remotely; my basic implementation looks like this:

class UNIXSocketDGram

  attr_reader :path

  private
  def sockaddr_struct_un(path)
    [Socket::AF_UNIX, path, 0].pack("Sa#{path.length}c")
  end

  private
  def initialize(path="/tmp/localunixdgram-#{$$}-#{rand(1000000)}")
    @proxy = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0)
    @proxy.bind(sockaddr_struct_un(path))
    @path = path
  end
  
  public
  def send(data, flags, dest)
    @proxy.send(data, flags, sockaddr_struct_un(dest))
  end
  
  public
  def recvfrom(len)
    data, sender = @proxy.recvfrom(len)
    return [data, [sender]]
  end
end

My problem is that it seems possible to call @proxy.send to a socket which 
causes the Ruby process to block regardless of signals.  I've tried a fairly 
desperate Kernel.syscall(27, 1) (i.e. deliver SIGALRM after 1 sec) to try to 
break such a blocking call, but still it hangs until I deliver a SIGTERM.

This only seems to happen when trying to talk to a UNIX socket which is being 
handled by a hung User-Mode Linux process: my question is, I suppose, whether 
I can do anything in Ruby to avert this hanging / blocking effect, or whether 
I can detect that it might happen before calling send on the socket.

Any ideas would be appreciated.

-- 
Matthew          > http://www.soup-kitchen.net/
                 > ICQ 19482073 > AIM MattbeeUK