From ba3b4e0a69e27f032179297cc9aed19472426558 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 29 Oct 2015 14:28:16 +0000 Subject: 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 --- test/ruby/test_io.rb | 8 +++++++- test/ruby/test_process.rb | 6 ++++-- version.h | 2 +- 3 files changed, 12 insertions(+), 4 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 diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 6bec5ba4cc..28e08ced2b 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1448,7 +1448,7 @@ class TestProcess < Test::Unit::TestCase end def test_aspawn_too_long_path - bug4315 = '[ruby-core:34833]' + bug4315 = '[ruby-core:34833] #7904 [ruby-core:52628] #11613' assert_fail_too_long_path(%w"echo |", bug4315) end @@ -1458,11 +1458,13 @@ class TestProcess < Test::Unit::TestCase cmds = Array.new(min, cmd) exs = [Errno::ENOENT] exs << Errno::E2BIG if defined?(Errno::E2BIG) + opts = {[STDOUT, STDERR]=>File::NULL} + opts[:rlimit_nproc] = 128 if defined?(Process::RLIMIT_NPROC) EnvUtil.suppress_warning do assert_raise(*exs, mesg) do begin loop do - Process.spawn(cmds.join(sep), [STDOUT, STDERR]=>File::NULL) + Process.spawn(cmds.join(sep), opts) min = [cmds.size, min].max cmds *= 100 end diff --git a/version.h b/version.h index ace0fd59fe..b69e88276a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.8" #define RUBY_RELEASE_DATE "2015-10-29" -#define RUBY_PATCHLEVEL 408 +#define RUBY_PATCHLEVEL 409 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 10 -- cgit v1.2.3