From: Gary Wright Date: 2008-05-21T03:36:54+09:00 Subject: Re: Arbitrary IO object On May 20, 2008, at 1:34 PM, Daniel Berger wrote: > > info = Process.create( > input = IO.new(x, 'w+') # Want next available fd > output = IO.new(y, 'w+') # Want next available fd > error = IO.new(z, 'w+') # Want next available fd > > :app_name => command, > :creation_flags => Process::DETACHED_PROCESS, > :startup_info => { > :stdin => input, > :stdout => output, > :stderr => error > } > ) IO.new is for associating a Ruby IO object with an already open OS file descriptor. So you've got to acquire the file descriptor through some non-Ruby mechanism in order to be useful via IO.new. You can use IO#fileno to discover the underlying OS file descriptor from a Ruby object but if you've already got a Ruby IO object you don't need to use IO.new. At the C/POSIX level I don't think there is really any concept of specifying the 'next available fd'. You just call open/create/pipe/dup and use the integer file descriptors that are returned. The OS figures out which integer descriptors are available. Gary Wright