summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_notimp.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb
index 10affd6c81..9721723b29 100644
--- a/test/ruby/test_notimp.rb
+++ b/test/ruby/test_notimp.rb
@@ -23,26 +23,28 @@ class TestNotImplement < Test::Unit::TestCase
def test_call_fork
GC.start
pid = nil
- begin
- Timeout.timeout(5) {
- pid = fork {}
- Process.wait pid
- pid = nil
- }
- rescue Timeout::Error
+ ps =
case RUBY_PLATFORM
when /linux/ # assume Linux Distribution uses procps
- ps = `ps -eLf #{pid}`
+ proc {`ps -eLf #{pid}`}
when /freebsd/
- ps = `ps -lH #{pid}`
+ proc {`ps -lH #{pid}`}
when /darwin/
- ps = `ps -lM #{pid}`
+ proc {`ps -lM #{pid}`}
else
- ps = `ps -l #{pid}`
+ proc {`ps -l #{pid}`}
end
+ assert_nothing_raised(Timeout::Error, ps) do
+ Timeout.timeout(5) {
+ pid = fork {}
+ Process.wait pid
+ pid = nil
+ }
+ end
+ ensure
+ if pid
Process.kill(:KILL, pid)
Process.wait pid
- assert_equal nil, pid, ps
end
end if Process.respond_to?(:fork)