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 + ps = + case RUBY_PLATFORM + when /linux/ # assume Linux Distribution uses procps + proc {`ps -eLf #{pid}`} + when /freebsd/ + proc {`ps -lH #{pid}`} + when /darwin/ + proc {`ps -lM #{pid}`} + else + proc {`ps -l #{pid}`} + end + assert_nothing_raised(Timeout::Error, ps) do Timeout.timeout(5) { pid = fork {} Process.wait pid pid = nil } - rescue Timeout::Error - case RUBY_PLATFORM - when /linux/ # assume Linux Distribution uses procps - ps = `ps -eLf #{pid}` - when /freebsd/ - ps = `ps -lH #{pid}` - when /darwin/ - ps = `ps -lM #{pid}` - else - ps = `ps -l #{pid}` - end + end + ensure + if pid Process.kill(:KILL, pid) Process.wait pid - assert_equal nil, pid, ps end end if Process.respond_to?(:fork)