summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 2283221d9c..03a7faa2dc 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1067,7 +1067,10 @@ class TestIO < Test::Unit::TestCase
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)