From: "ara.t.howard" Date: 2008-07-18T02:01:40+09:00 Subject: Re: Reading stdout & stderr from a pipe with popen3 On Jul 17, 2008, at 10:53 AM, Matt Mencel wrote: > def runner(stdin, stdout, stderr, cmd) > queue = Queue.new > stdin.puts(cmd) stdin.flush > > errthd = Thread.new do > Thread.current.abort_on_exception = true > while(( line = stderr.gets )) > queue.push(line) > end > queue.push :stderr_done > end > > outthd = Thread.new do > Thread.current.abort_on_exception = true > while(( line = stdout.gets )) > queue.push(line) > end > queue.push :stdout_done > end > > inthd = Thread.new do > Thread.current.abort_on_exception = true > while(( stuff = queue.pop )) > puts stuff > break if :stdout_done and :stderr_done this test reads "break if true and true" !?! you are testing truth on two symbols. you need to keep vars and set them when :stdout_done and :stderr_done are seen on the queue. if stuff == :stdout_done stdout_done == true next end if stuff == :stderr_done stderr_done = true next end if stdout_done and stderr_done end etc... btw - you are simply re-writing the open4 gem - why not use it? > > end > end > > inthd.join > errthd.exit > outthd.exit > end a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama