i'm working on an tk ap that drives alot of complex code, some of which is not
even ruby, and essitially gives you running progress report.  i've had no end
to the woes one can get into by mixing threads and forks with tk.  some
combinations even seem to hang X... in any case, the cause of the forks is
mostly open3 and i'm considering this alternative:

    def spawn command
      ipath = tmpfifo
      opath = tmpfifo
      epath = tmpfifo

      cmd = "#{ command } < #{ ipath } 1> #{ opath } 2> #{ epath } &"
      system cmd

      i = open ipath, 'w'
      o = open opath, 'r'
      e = open epath, 'r'

      [i,o,e]
    end

    def tmpfifo
      path = nil
      42.times do |i|
        tpath = File.join(Dir.tmpdir, "#{ $$ }.#{ rand }.#{ i }")
        system "mkfifo #{ tpath }"
        next unless $? == 0
        path = tpath
        at_exit{ File.unlink path rescue STDERR.puts "rm <#{ path }> failed" }
        break
      end
      raise "could not generate tmpfifo" unless path
      path
    end

obviously this is a non-portable alternative - but then again so is open3.  can
anyone see any large drawbacks to this?  it plays well with threads and tk
since one can:

  i,o,e = spawn 'sh'
  i.puts long_running_command

  Thread.new do
    while((out = o.gets))
    ... 
      update widgets with out
    ... 
    end
  end

  Thread.new do
    while((err = e.gets))
    ... 
      update widgets with err 
    ... 
    end
  end

-a
-- 
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL     :: http://www.ngdc.noaa.gov/stp/
| TRY     :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done 
===============================================================================