From: "kosaki (Motohiro KOSAKI)" Date: 2013-02-15T05:03:28+09:00 Subject: [ruby-core:52265] [ruby-trunk - Bug #7826] test_setsid rarely fails with Errno::ESRCH at Process.getsid(io.pid) Issue #7826 has been updated by kosaki (Motohiro KOSAKI). Thanks nagachika-san. I realized MacOS X's getsid() wrongly return ESRCH when target process is zombie. I fully agree your patch is good workaround and I committed it. ---------------------------------------- Bug #7826: test_setsid rarely fails with Errno::ESRCH at Process.getsid(io.pid) https://bugs.ruby-lang.org/issues/7826#change-36296 Author: nagachika (Tomoyuki Chikanaga) Status: Closed Priority: Normal Assignee: kosaki (Motohiro KOSAKI) Category: test Target version: ruby -v: ruby 2.0.0dev (2013-02-11 trunk 39204) [x86_64-darwin10.8.0] I've just encountered the following fault in make test-all. [ 8077/13116] TestProcess#test_setsid = 0.06 s 2) Error: test_setsid(TestProcess): Errno::ESRCH: No such process /Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_process.rb:1592:in `getsid' /Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_process.rb:1592:in `block in test_setsid' /Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_process.rb:1581:in `popen' /Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_process.rb:1581:in `test_setsid' I think child process could terminate before calling Process.getsid for its pid. how about the following patch? Process.kill in in ensure-clause guarantee the child process will be terminated. diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 96335c2..3a69580 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1583,6 +1583,7 @@ class TestProcess < Test::Unit::TestCase newsid = Process.setsid Marshal.dump(newsid, STDOUT) STDOUT.flush + sleep EOS begin # test Process.getsid() w/o arg -- http://bugs.ruby-lang.org/