From: Worky Workerson Date: 2007-03-21T02:12:33+09:00 Subject: Re: Passing File Descriptors? On 3/19/07, Gary Wright wrote: > > On Mar 19, 2007, at 12:43 PM, Worky Workerson wrote: > > Is there a ruby way to pass file descriptors to separate processes? > > I'm thinking of interfacing with a C program, which uses the > > SCM_RIGHTS cmsg over a unix-domain socket ... is this idiom > > implemented in Ruby? How would I marshall an IO object into (and out > > of) the integer file descriptor, or does this "just work"? > > After a little investigation, this turned out to be easier than > I thought. ... > clientfile = client.recv_io > puts "parent received fd: #{clientfile.fileno}, contents:" Sweet, thanks! I guess I had missed the {send,recv}_io methods. They're not in the Ruby book ... guess I should have done to the online docs. Ruby does make this trivial ... even works with my existing C program. -Mike