From: James Edward Gray II Date: 2007-04-19T22:34:47+09:00 Subject: Re: Executing program from ruby On Apr 19, 2007, at 8:21 AM, Marcin Raczkowski wrote: > any expirience with open4? help? pointers? TextMate uses a hand-rolled popen3(), which is really just an open4() clone. Allan Odgaard, the creator of TextMate, wrote the code, but it's straightforward enough that I thought it might help you to see it: def my_popen3(*cmd) # returns [stdin, stdout, strerr, pid] pw = IO::pipe # pipe[0] for read, pipe[1] for write pr = IO::pipe pe = IO::pipe pid = fork{ pw[1].close STDIN.reopen(pw[0]) pw[0].close pr[0].close STDOUT.reopen(pr[1]) pr[1].close pe[0].close STDERR.reopen(pe[1]) pe[1].close exec(*cmd) } pw[0].close pr[1].close pe[1].close pw[1].sync = true [pw[1], pr[0], pe[0], pid] end Hope that helps. James Edward Gray II