From: Robert Klemme Date: 2003-05-08T20:50:29+09:00 Subject: Re: IO.pipe + thread = hangs (was: Re: capture output) This is a multi-part message in MIME format. ------=_NextPart_000_00EA_01C31566.3D972930 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit schrieb im Newsbeitrag news:200305081052.h48AqYeR008509@sharui.nakada.kanuma.tochigi.jp... > Hi, > > At Thu, 8 May 2003 16:49:22 +0900, > Robert Klemme wrote: > > A bit more testing reveals that this seems to be a problem of the mswin > > version: > > IO multiplexing on pipes doesn't work on Windows. It's a known > restriction. Ah! Thanks a lot for clearing this! I would have thought that a file descriptor pointing to a pipe end is the same as a file descriptor pointing to a terminal or file, but then - it's windows... *sigh* > > I noticed also, that closing STDERR or $stderr does seem to close STDOUT, > > too. Is this intended behavior or is it a known bug? > > Neither. Could you detail? This worked for me, at least. > > $ ruby16-mswin -e 'STDERR.close; puts "hello"' > hello True for me, too. Apparently I draw the wrong conclusion while experimenting with pipe redirecting. One of the scripts I was using for experiments (see attached) did seem to eat STDOUT output when STDERR was closed. Strange, though. Kind regards robert ------=_NextPart_000_00EA_01C31566.3D972930 Content-Type: application/octet-stream; name="capture-4.rb" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="capture-4.rb" #!/usr/bin/ruby -w=0A= =0A= STDOUT.sync=3D true=0A= =0A= rd, wr =3D IO.pipe=0A= =0A= reader =3D Thread.new do=0A= buffer =3D ""=0A= =0A= rd.each do |line|=0A= buffer << line=0A= end=0A= =0A= rd.close=0A= =0A= buffer=0A= end=0A= =0A= # when uncommenting the next line NO output occurs,=0A= # even STDOUT is silent:=0A= # STDERR.close=0A= STDERR.reopen wr=0A= =0A= puts "Sending message to parent"=0A= STDERR.write "Hi Dad"=0A= wr.close=0A= =0A= puts "Parent got: <#{reader.value}>"=0A= ------=_NextPart_000_00EA_01C31566.3D972930--