Source

fdpass /

Filename Size Date modified Message
ext
49 B
162 B
631 B
525 B
= fdpass

== Description

This is a library to transmit the file descriptor between the processes. 

== Install

gem install fdpass

== Example
=== Server (Reciever)
  require 'fdpass'
  
  begin
    fdpass = FDPass.server('/tmp/fdpass.sock')
  
    t = Thread.fork {
      loop do
        fd = fdpass.recv
        io = IO.open(fd)
        io.puts('%s: %s' % [fd, __FILE__])
        fd.close
      end
    }

    t.join
  ensure
    fdpass.close
  end

== Client (Sender)
  require 'fdpass'
  
  begin
    fdpass = FDPass.client('/tmp/fdpass.sock')
    fdpass.send($stderr.fileno)
  ensure
    fdpass.close if fdpass.closed?
  end