summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/open3.rb57
2 files changed, 20 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index bb1e1a423b..47bb3e69e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Apr 27 01:46:29 2008 Tanaka Akira <akr@fsij.org>
+
+ * lib/open3.rb (Open3.popen3w): removed.
+ (Open3.popen3): notice wait_thr.
+
Sun Apr 27 01:13:05 2008 Eric Hodel <drbrain@segment7.net>
* lib/rdoc, test/rdoc: Update to RDoc 2.0.0 r56.
diff --git a/lib/open3.rb b/lib/open3.rb
index ada2b4fbd8..f707f55409 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -9,65 +9,38 @@
#
#
-# Open3 grants you access to stdin, stdout, and stderr when running another
-# program. Example:
+# Open3 grants you access to stdin, stdout, stderr and a thread to wait the
+# child process when running another program.
+#
+# Example:
#
# require "open3"
# include Open3
#
-# stdin, stdout, stderr = popen3('nroff -man')
+# stdin, stdout, stderr, wait_thr = popen3('nroff -man')
#
-# If the exit status of the child process is required, Open3.popen3w is usable.
+# Open3.popen3 can also take a block which will receive stdin, stdout,
+# stderr and wait_thr as parameters.
+# This ensures stdin, stdout and stderr are closed and
+# the process is terminated 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:
+# Example:
#
# require "open3"
#
-# Open3.popen3('nroff -man') { |stdin, stdout, stderr| ... }
+# Open3.popen3('nroff -man') { |stdin, stdout, stderr, wait_thr| ... }
#
module Open3
#
# Open stdin, stdout, and stderr streams and start external executable.
- #
- # Non-block form:
- #
- # stdin, stdout, stderr = Open3.popen3(cmd)
- # ...
- # stdin.close # stdin, stdout and stderr should be closed in this form.
- # stdout.close
- # stderr.close
- #
- # Block form:
- #
- # Open3.popen3(cmd) { |stdin, stdout, stderr| ... }
- # # stdin, stdout and stderr is closed automatically in this form.
- #
- # The parameter +cmd+ is passed directly to Kernel#spawn.
- #
- def popen3(*cmd)
- if defined? yield
- popen3w(*cmd) {|stdin, stdout, stderr, wait_thr|
- yield stdin, stdout, stderr
- }
- else
- stdin, stdout, stderr, wait_thr = popen3w(*cmd)
- return stdin, stdout, stderr
- end
- end
- module_function :popen3
-
- #
- # Open stdin, stdout, and stderr streams and start external executable.
# In addition, a thread for waiting the started process is noticed.
# The thread has a thread variable :pid which is the pid of the started
# process.
#
# Non-block form:
#
- # stdin, stdout, stderr, wait_thr = Open3.popen3w(cmd)
+ # stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
# pid = wait_thr[:pid] # pid of the started process.
# ...
# stdin.close # stdin, stdout and stderr should be closed in this form.
@@ -77,7 +50,7 @@ module Open3
#
# Block form:
#
- # Open3.popen3w(cmd) { |stdin, stdout, stderr, wait_thr| ... }
+ # Open3.popen3(cmd) { |stdin, stdout, stderr, wait_thr| ... }
#
# The parameter +cmd+ is passed directly to Kernel#spawn.
#
@@ -86,7 +59,7 @@ module Open3
#
# Closing stdin, stdout and stderr does not wait the process.
#
- def popen3w(*cmd)
+ def popen3(*cmd)
pw = IO::pipe # pipe[0] for read, pipe[1] for write
pr = IO::pipe
pe = IO::pipe
@@ -109,7 +82,7 @@ module Open3
end
pi
end
- module_function :popen3w
+ module_function :popen3
end
if $0 == __FILE__