From: "Berger, Daniel" <Daniel.Berger / qwest.com> > > From: Bill Kelly [mailto:billk / cts.com] > > > There must be *some* way to do a non-blocking pipe read > > on windows...??? (I saw Nobu's io-wait module on RAA, > > that would add a #ready? method. Even that might help; > > although I don't know if io-wait works on Windows or not. The > > download link seems to be broken...) > > With the standard Ruby library? Dunno. > > However, perhaps win32-pipe can do what you want, though the API will be > different. Oh, and ignore the docs that say asynchronous pipes aren't > supported. Support was added in 0.1.0 - I need to update the docs. Cool, thanks. I'll probably go with sockets so my solution is platform-portable. But you guys seem to be doing fantastic work on the win32 utils. Do you anticipate that things like your win32 fork() will become part of the ruby core? BTW, for completeness in the context of the nonblocking thread, my planned solution is to make a small wrapper module for spawning an external process, which can use popen() to run the desired subprocess, but talk back to the parent process via sockets. I.e. instead of io = IO.popen("command...") do sock, child_io = socket_popen("command...") which will have to do something like: def socket_popen(cmd) sv = TCPServer.new(0) sv_port = sv.addr[1] middleman = IO.popen("ruby -rsocket -e 'in=IO.popen(#{cmd}); " + "out=TCPSocket.new(%{localhost}, #{sv_port}); " + "out.puts(line) while(line=in.gets); " + "in.close; out.close'") sock = sv.accept # TO-DO: add timeout sv.close [sock, middleman] end ... Bleah :( And that implementation is only for reading for the child process, but that's all I need at present. And so the idea is: sock, child_io = socket_popen("command...") child_io is effectively a dummy as no data will ever be returned on that pipe, but can be used to obtain the pid of the child. All the child's output will come back on sock, which - yay - at least select() will work on in win32 (and with the earlier mentioned patch from Jean-Francois Nadeau could even be nonblocking.) If anyone knows a less ugly way to do what I'm trying to do above that's platform-portable, please do comment.... Thanks, Bill