summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 14:28:16 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 14:28:16 +0000
commitba3b4e0a69e27f032179297cc9aed19472426558 (patch)
tree0047f7e8e71e0bf5e8900e0f67e1da88514aa72e /test/ruby/test_io.rb
parent9008fda66f28a28074088fb711488ae06ab72eba (diff)
merge revision(s) 52229,52273,52277,52357: [Backport #11613]
Add rlimit_nproc to avoid to create many process [Bug #11613] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@52358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 18e37d6d0b..5d00f04ef5 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1048,7 +1048,9 @@ class TestIO < Test::Unit::TestCase
def ruby(*args)
args = ['-e', '$>.write($<.read)'] if args.empty?
ruby = EnvUtil.rubybin
- f = IO.popen([ruby] + args, 'r+')
+ opts = {}
+ opts[:rlimit_nproc] = 1024 if defined?(Process::RLIMIT_NPROC)
+ f = IO.popen([ruby] + args, 'r+', opts)
pid = f.pid
yield(f)
ensure
@@ -1099,6 +1101,10 @@ class TestIO < Test::Unit::TestCase
def test_dup_many
ruby('-e', <<-'End') {|f|
+ if defined?(Process::RLIMIT_NOFILE)
+ lim = Process.getrlimit(Process::RLIMIT_NOFILE)[0]
+ Process.setrlimit(Process::RLIMIT_NOFILE, [lim, 1024].min)
+ end
ok = 0
a = []
begin