From: Daniel Berger Date: 2008-05-21T02:34:08+09:00 Subject: Re: Arbitrary IO object On May 20, 11:25 am, Robert Klemme wrote: > On 20.05.2008 18:40, Daniel Berger wrote: > > > How would I go about using IO.new such that it would automatically > > grab the next available file descriptor? > > Not sure what you mean: File.open uses a new file descriptor.  Why would > you care about the file descriptor numbering? > > > I don't know the fileno in > > advance and I can't use StringIO. > > Why would you want to use StringIO to read from files? > > > What are my options? > > What are you trying to achieve? I'm tinkering with possibly reimplementing win32-open3 using the win32- process library. You can redirect stdin, stdout and stderr like so: 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 } ) pid = info.process_id return [input, output, error, pid] That's the general idea, anyway. Regards, Dan