summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io.c2
-rw-r--r--test/ruby/test_process.rb30
-rw-r--r--version.h2
3 files changed, 24 insertions, 10 deletions
diff --git a/io.c b/io.c
index 1e403b676e..17f8d5799a 100644
--- a/io.c
+++ b/io.c
@@ -8002,7 +8002,7 @@ popen_finish(VALUE port, VALUE klass)
if (NIL_P(port)) {
/* child */
if (rb_block_given_p()) {
- rb_yield(Qnil);
+ rb_protect(rb_yield, Qnil, NULL);
rb_io_flush(rb_ractor_stdout());
rb_io_flush(rb_ractor_stderr());
_exit(0);
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index d9804aaa57..ffcca99eb3 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -923,15 +923,29 @@ class TestProcess < Test::Unit::TestCase
}
end
- def test_popen_fork
- IO.popen("-") {|io|
- if !io
- puts "fooo"
- else
- assert_equal("fooo\n", io.read)
+ if Process.respond_to?(:fork)
+ def test_popen_fork
+ IO.popen("-") do |io|
+ if !io
+ puts "fooo"
+ else
+ assert_equal("fooo\n", io.read)
+ end
end
- }
- rescue NotImplementedError
+ end
+
+ def test_popen_fork_ensure
+ IO.popen("-") do |io|
+ if !io
+ STDERR.reopen(STDOUT)
+ raise "fooo"
+ else
+ assert_empty io.read
+ end
+ end
+ rescue RuntimeError
+ abort "[Bug #20995] should not reach here"
+ end
end
def test_fd_inheritance
diff --git a/version.h b/version.h
index 5acde54440..ea795cad3f 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 120
+#define RUBY_PATCHLEVEL 121
#include "ruby/version.h"
#include "ruby/internal/abi.h"