Issue #7826 has been updated by kosaki (Motohiro KOSAKI).

Status changed from Assigned to Closed

Sorry, my fault.
but I think it was already fixed at r39179. (thx narse-san)

----------------------------------------
Bug #7826: test_setsid rarely fails with Errno::ESRCH at Process.getsid(io.pid)
https://bugs.ruby-lang.org/issues/7826#change-36148

Author: nagachika (Tomoyuki Chikanaga)
Status: Closed
Priority: Normal
Assignee: kosaki (Motohiro KOSAKI)
Category: test
Target version: 
ruby -v: ruby 2.0.0dev (2012-12-30 trunk 38661) [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/