diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-10-20 16:37:01 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-10-20 16:37:01 +0000 |
| commit | 811ec08f39f69dbb8a162d2c27c350e4a7f82c17 (patch) | |
| tree | 46efc0ee553a8d4009758a4b18b4b52259923408 /lib/open3.rb | |
| parent | 1d85625b8781445af6a1dc8915129b14d33a4c8a (diff) | |
| download | ruby-811ec08f39f69dbb8a162d2c27c350e4a7f82c17.tar.gz ruby-811ec08f39f69dbb8a162d2c27c350e4a7f82c17.tar.xz ruby-811ec08f39f69dbb8a162d2c27c350e4a7f82c17.zip | |
matz
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open3.rb')
| -rw-r--r-- | lib/open3.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/open3.rb b/lib/open3.rb index 27283f501..11b9813be 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -14,8 +14,8 @@ module Open3 pr = IO::pipe pe = IO::pipe - pid = fork - if pid == nil then # child + pid = fork{ + # child pw[1].close STDIN.reopen(pw[0]) pw[0].close @@ -29,13 +29,21 @@ module Open3 pe[1].close exec(cmd) - exit - else - pw[0].close - pr[1].close - pe[1].close - pi = [ pw[1], pr[0], pe[0] ] + _exit 127 + } + + pw[0].close + pr[1].close + pe[1].close + Thread.start do + sleep 1 + Process.waitpid(pid) + end + pi = [ pw[1], pr[0], pe[0] ] + if defined? yield + return yield *pi end + pi end module_function :popen3 end |
