use fork to isolate rlimit effect.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b5d9d7086
commit
ad5f0fc6cc
@ -21,12 +21,17 @@ class TestProcess < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_rlimit_nofile
|
def test_rlimit_nofile
|
||||||
return unless rlimit_exist?
|
return unless rlimit_exist?
|
||||||
|
pid = fork {
|
||||||
cur_nofile, max_nofile = Process.getrlimit(Process::RLIMIT_NOFILE)
|
cur_nofile, max_nofile = Process.getrlimit(Process::RLIMIT_NOFILE)
|
||||||
Process.setrlimit(Process::RLIMIT_NOFILE, 0, max_nofile)
|
Process.setrlimit(Process::RLIMIT_NOFILE, 0, max_nofile)
|
||||||
begin
|
begin
|
||||||
assert_raise(Errno::EMFILE) { IO.pipe }
|
IO.pipe
|
||||||
ensure
|
rescue Errno::EMFILE
|
||||||
Process.setrlimit(Process::RLIMIT_NOFILE, cur_nofile, max_nofile)
|
exit 0
|
||||||
end
|
end
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Process.wait pid
|
||||||
|
assert_equal(0, $?.to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user