From adbdf11f94afd52d276c7891515e0eb808f6003f Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 18 Jun 2020 16:01:36 +0200 Subject: [open3] only close streams if a block is passed Ref: 5429deb075beb9a2b67adae269bbac16325876d1 The previous change totally borke `popen2e` in this usage: ```ruby require 'open3' stdin, stdout, process = Open3.popen2e("cat") puts stdout.read ``` --- lib/open3.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/open3.rb b/lib/open3.rb index ada451c249..3ee81c30ac 100644 --- a/lib/open3.rb +++ b/lib/open3.rb @@ -207,10 +207,12 @@ module Open3 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 + if block + in_r.close + in_w.close + out_r.close + out_w.close + end end module_function :popen2e -- cgit v1.2.1