summaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-21 07:08:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-21 07:08:34 +0000
commitb6257ecd86ddb5042bc6fbfde541b8df8c65db95 (patch)
tree1cd344953e0683610b1e1000194a463a6c5ae46c /test/ruby
parent82875c077c6f242bb339386932da1b31f0355db8 (diff)
downloadruby-b6257ecd86ddb5042bc6fbfde541b8df8c65db95.tar.gz
ruby-b6257ecd86ddb5042bc6fbfde541b8df8c65db95.tar.xz
ruby-b6257ecd86ddb5042bc6fbfde541b8df8c65db95.zip
use fork to isolate rlimit effect.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-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 5c3035ea9..dc04c60f4 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