diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-09 14:49:49 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-09 14:49:49 +0000 |
commit | 025e3243f26103d086854312ef83477a04a72cff (patch) | |
tree | f899cdae77850820e17d14e7e0536e646edea623 /lib/open3.rb | |
parent | 12bcd06f4fa26ad8fe37049e21d008929de2eea9 (diff) | |
download | ruby-025e3243f26103d086854312ef83477a04a72cff.tar.gz ruby-025e3243f26103d086854312ef83477a04a72cff.tar.xz ruby-025e3243f26103d086854312ef83477a04a72cff.zip |
* lib/parsedate.rb: documentation patch from Konrad Meyer
<konrad.meyer@gmail.com>. [ruby-doc:1238]
* lib/open3.rb, lib/ping.rb: ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open3.rb')
-rw-r--r-- | lib/open3.rb | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/lib/open3.rb b/lib/open3.rb index f722252b1..c4dacc947 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -1,29 +1,48 @@ -# open3.rb: Spawn a program like popen, but with stderr, too. You might also -# want to use this if you want to bypass the shell. (By passing multiple args, -# which IO#popen does not allow) # -# Usage: +# = open3.rb: Popen, but with stderr, too # -# require "open3" -# -# stdin, stdout, stderr = Open3.popen3('nroff -man') +# Author:: Yukihiro Matsumoto +# Documentation:: Konrad Meyer +# +# Open3 gives you access to stdin, stdout, and stderr when running other +# programs. +# + # -# or: +# Open3 grants you access to stdin, stdout, and stderr when running another +# program. Example: # +# require "open3" # include Open3 # # stdin, stdout, stderr = popen3('nroff -man') # -# popen3 can also take a block which will receive stdin, stdout and stderr as -# parameters. This ensures stdin, stdout and stderr are closed once the block -# exits. +# Open3.popen3 can also take a block which will receive stdin, stdout and +# stderr as parameters. This ensures stdin, stdout and stderr are closed +# once the block exits. Example: # -# Such as: +# require "open3" # # Open3.popen3('nroff -man') { |stdin, stdout, stderr| ... } +# module Open3 - #[stdin, stdout, stderr] = popen3(command); + # + # Open stdin, stdout, and stderr streams and start external executable. + # Non-block form: + # + # require 'open3' + # + # [stdin, stdout, stderr] = Open3.popen3(cmd) + # + # Block form: + # + # require 'open3' + # + # Open3.popen3(cmd) { |stdin, stdout, stderr| ... } + # + # The parameter +cmd+ is passed directly to Kernel#exec. + # def popen3(*cmd) pw = IO::pipe # pipe[0] for read, pipe[1] for write pr = IO::pipe |