Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/io/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,10 @@ io_getpass(int argc, VALUE *argv, VALUE io)
void
Init_console(void)
{
#ifdef HAVE_RB_EXT_RACTOR_SAFE
RB_EXT_RACTOR_SAFE(true);
#endif

#undef rb_intern
id_getc = rb_intern("getc");
id_gets = rb_intern("gets");
Expand Down
24 changes: 24 additions & 0 deletions test/io/console/test_ractor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require 'test/unit'
require 'rbconfig'

class TestIOConsoleInRactor < Test::Unit::TestCase
def test_ractor
ext = "/io/console.#{RbConfig::CONFIG['DLEXT']}"
path = $".find {|path| path.end_with?(ext)}
assert_in_out_err(%W[-r#{path}], "#{<<~"begin;"}\n#{<<~'end;'}", ["true"], [])
begin;
$VERBOSE = nil
r = Ractor.new do
$stdout.console_mode
rescue SystemCallError
true
rescue Ractor::UnsafeError
false
else
true # should not success
end
puts r.take
end;
end
end if defined? Ractor