On Tue, 3 Feb 2004, Patrick Bennett wrote:

> Date: Tue, 3 Feb 2004 06:03:48 +0900
> From: Patrick Bennett <patrick.bennett / inin.com>
> Newsgroups: comp.lang.ruby
> Subject: Re: Questions about stdout/stderr combining (for Windows & Linux)
> 
> Joel VanderWerf wrote:
> 
> > What about separate pipes, two threads reading them and putting 
> > messages in a queue, and a third thread pulling messages in from the 
> > queue?
> 
> It wouldn't work.  Messages could still appear out of order unfortunately.

why not use ruby to do the deed for you?

  ~/eg/ruby > cat a.rb
  #!/usr/bin/env ruby
  require 'rbconfig'

  class Spawn
    class << self; alias [] new; end
    RUBY = File.join(Config::CONFIG["bindir"], Config::CONFIG["ruby_install_name"]) 
    PROGRAM = <<-code
      STDERR.reopen(STDOUT)
      exec(*ARGV)
    code
    attr :out
    def initialize argv
      @out = `#{ RUBY } -e '#{ PROGRAM }' #{ argv.join(' ') }`
    end
  end

  stdout_stderr = Spawn[ ARGV ].out
  puts "STDOUT_STDERR:\n"
  puts stdout_stderr

  ~/eg/ruby > a.rb ls a.rb
  STDOUT_STDERR:
  a.rb

  ~/eg/ruby > a.rb ls does-not-exist
  STDOUT_STDERR:
  ls: does-not-exist: No such file or directory


i have not tested this on windows - but something like this should work.

-a
-- 

ATTN: please update your address books with address below!

===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP     :: http://www.ngdc.noaa.gov/stp/
| NGDC    :: http://www.ngdc.noaa.gov/
| NESDIS  :: http://www.nesdis.noaa.gov/
| NOAA    :: http://www.noaa.gov/
| US DOC  :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.  
| Art is everything else.  
|   -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' 
===============================================================================