diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2020-05-27 00:20:14 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2020-05-27 00:20:14 +0900 |
commit | 5429deb075beb9a2b67adae269bbac16325876d1 (patch) | |
tree | 593aee9ad2ceeaf434c46390ac52aba8743f82e9 | |
parent | eb20d2f449d299b9281abd2426878deeb8ebcdad (diff) | |
download | ruby-5429deb075beb9a2b67adae269bbac16325876d1.tar.gz |
lib/open3.rb: make sure that pipes are closed
Attempting to invoke a non-existent command led to the leak of fds.
http://rubyci.s3.amazonaws.com/graviton2/ruby-master/log/20200526T140004Z.log.html.gz
```
[ 9101/20195] TestGemExtCmakeBuilder#test_self_build = 0.01 sLeaked file descriptor: TestGemExtCmakeBuilder#test_self_build: 7 : #<IO:fd 7>
Leaked file descriptor: TestGemExtCmakeBuilder#test_self_build: 10 : #<IO:fd 10>
Leaked file descriptor: TestGemExtCmakeBuilder#test_self_build: 11 : #<IO:fd 11>
Leaked file descriptor: TestGemExtCmakeBuilder#test_self_build: 12 : #<IO:fd 12>
```
-rw-r--r-- | lib/open3.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/open3.rb b/lib/open3.rb index 5e725317a4..ada451c249 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -206,6 +206,11 @@ module Open3 opts[[:out, :err]] = out_w popen_run(cmd, opts, [in_r, out_w], [in_w, out_r], &block) + ensure + in_r.close + in_w.close + out_r.close + out_w.close end module_function :popen2e |