summaryrefslogtreecommitdiff
path: root/test/ruby/test_process.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_process.rb')
-rw-r--r--test/ruby/test_process.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 5c3035ea93..dc04c60f40 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -21,12 +21,17 @@ class TestProcess < Test::Unit::TestCase
def test_rlimit_nofile
return unless rlimit_exist?
- cur_nofile, max_nofile = Process.getrlimit(Process::RLIMIT_NOFILE)
- Process.setrlimit(Process::RLIMIT_NOFILE, 0, max_nofile)
- begin
- assert_raise(Errno::EMFILE) { IO.pipe }
- ensure
- Process.setrlimit(Process::RLIMIT_NOFILE, cur_nofile, max_nofile)
- end
+ pid = fork {
+ cur_nofile, max_nofile = Process.getrlimit(Process::RLIMIT_NOFILE)
+ Process.setrlimit(Process::RLIMIT_NOFILE, 0, max_nofile)
+ begin
+ IO.pipe
+ rescue Errno::EMFILE
+ exit 0
+ end
+ exit 1
+ }
+ Process.wait pid
+ assert_equal(0, $?.to_i)
end
end