diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-16 23:56:08 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-16 23:56:08 +0000 |
commit | b53fadfd5f200dbd6fe9f4b2a91ebb68618e59bb (patch) | |
tree | 460743a4634657cb7161c682a6e05b248e7a8d37 /process.c | |
parent | 2cf3bd5bb2a7c4724e528577d37a883fe80a1122 (diff) | |
download | ruby-b53fadfd5f200dbd6fe9f4b2a91ebb68618e59bb.tar.gz |
process.c: defaults to close_others false
Arbitrarily closing file descriptors on exec breaks use cases
where a Ruby process sets up a descriptor for non-Ruby children
to use. For example, the "rake foo" target may spawn any number
of subprocesses (Ruby or not) which depends on parsing the "FOO"
environment variable for out_fd:99 and writing to foo.out
FOO=out_fd:99 rake foo 99>>foo.out
Unfortunately, this introduced one incompatibility in
test/lib/test/unit.rb and it now requires explicitly setting
IO#close_on_exec=true
[ruby-core:88007] [Misc #14907]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -3496,7 +3496,7 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp, } #ifdef HAVE_WORKING_FORK - if (!eargp->close_others_given || eargp->close_others_do) { + if (eargp->close_others_do) { rb_close_before_exec(3, eargp->close_others_maxhint, eargp->redirect_fds); /* async-signal-safe */ } #endif @@ -4568,7 +4568,7 @@ rb_f_system(int argc, VALUE *argv) * integer : the file descriptor of specified the integer * io : the file descriptor specified as io.fileno * file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not - * :close_others => true : don't inherit + * :close_others => false : inherit * current directory: * :chdir => str * @@ -4727,7 +4727,7 @@ rb_f_system(int argc, VALUE *argv) * pid = spawn(command, :close_others=>true) # close 3,4,5,... (default) * pid = spawn(command, :close_others=>false) # don't close 3,4,5,... * - * :close_others is true by default for spawn and IO.popen. + * :close_others is false by default for spawn and IO.popen. * * Note that fds which close-on-exec flag is already set are closed * regardless of :close_others option. |