From 8e8095dd885466fc379c2b033334c3d0f04ae507 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 25 Apr 2008 17:01:57 +0000 Subject: update spawn rdoc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'process.c') diff --git a/process.c b/process.c index 25349b6da6..a6fc8c7a06 100644 --- a/process.c +++ b/process.c @@ -2759,22 +2759,27 @@ rb_f_system(int argc, VALUE *argv) * # standard output and standard error is redirected to log file. * pid = spawn(command, [STDOUT, STDERR]=>["log", "w"]) * - * It is possible to specify a file descriptor to close using - * :close. + * spawn closes all non-standard unspecified descriptors by default. + * The "standard" descriptors are 0, 1 and 2. + * This behavior is specified by :close_others option. * - * # similar to IO.popen - * r, w = IO.pipe - * pid = spawn(command, STDOUT=>w, r=>:close, w=>:close) - * w.close + * pid = spawn(command, :close_others=>true) # close 3,4,5,... (default) + * pid = spawn(command, :close_others=>false) # don't close 3,4,5,... * - * Also, all non-standard unspecified descriptors can be closed by :close_others option. - * The "standard" descriptors are 0, 1 and 2. + * :close_others is true by default for spawn and IO.popen. * - * # more similar to IO.popen + * So IO.pipe and spawn can be used as IO.popen. + * + * # similar to r = IO.popen(command) * r, w = IO.pipe - * pid = spawn(command, STDOUT=>w, :close_others=>true) + * pid = spawn(command, STDOUT=>w) # r, w is closed in the child process. * w.close * + * :close is specified as a hash value to close a fd individualy. + * + * f = open(foo) + * system(command, f=>:close) # don't inherit f. + * * It is also possible to exchange file descriptors. * * pid = spawn(command, STDOUT=>STDERR, STDERR=>STDOUT) -- cgit v1.2.3