diff options
| author | Randy Stauner <randy.stauner@shopify.com> | 2026-05-12 11:43:52 -0700 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-05-14 21:17:54 +0000 |
| commit | 9a55fc506dfe26c7511c3bcd75fbf3dad295fa4a (patch) | |
| tree | ef30f012acee13e883b8b66b3ee6f3fb03c7b792 /test | |
| parent | ec106b10a9998734eadd9a6ad14ab8209b9da5cc (diff) | |
[ruby/rubygems] Close stdin immediately when using popen2e
It's good hygiene to close the stdin pipe as soon as you are done writing to it.
This can happen for example if "ruby extconf.rb" spawns another
process (for example "cargo build", which may spawn arbitrary commands
to fetch credentials) and any of those subprocesses attempt to read
STDIN until it is closed.
We can close it as soon as it's created since we aren't writing to it at all.
https://github.com/ruby/rubygems/commit/ab09bfdf10
Diffstat (limited to 'test')
| -rw-r--r-- | test/rubygems/test_gem_ext_builder.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index 5fcbc3e2ac..37204f3c47 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -106,6 +106,22 @@ install: assert_match(/install: OK/, results) end + def test_class_run_closes_stdin + results = [] + check_stdin_script = <<~'RUBY' + if IO.select([STDIN], nil, nil, 1) + puts "STDIN: #{STDIN.read.inspect}" + else + puts "NOT_READY" + end + RUBY + + Gem::Ext::Builder.run([Gem.ruby, "-e", check_stdin_script], results) + + command_output = results.last + assert_equal "STDIN: \"\"\n", command_output + end + def test_build_extensions pend "terminates on mswin" if vc_windows? && ruby_repo? |
