Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 53216) +++ test/ruby/test_io.rb (working copy) @@ -1094,7 +1094,10 @@ args = ['-e', '$>.write($<.read)'] if args.empty? ruby = EnvUtil.rubybin opts = {} - opts[:rlimit_nproc] = 1024 if defined?(Process::RLIMIT_NPROC) + if defined?(Process::RLIMIT_NPROC) + lim = Process.getrlimit(Process::RLIMIT_NPROC)[1] + opts[:rlimit_nproc] = [lim, 1024].min + end f = IO.popen([ruby] + args, 'r+', opts) pid = f.pid yield(f)