Backport #7826

test_setsid rarely fails with Errno::ESRCH at Process.getsid(io.pid)

Added by Tomoyuki Chikanaga about 1 year ago. Updated about 1 year ago.

[ruby-core:52126]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

Description

I've just encountered the following fault in make test-all.

[ 8077/13116] TestProcess#testsetsid = 0.06 s
2) Error:
test
setsid(TestProcess):
Errno::ESRCH: No such process
/Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/testprocess.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/testprocess.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/testprocess.rb b/test/ruby/testprocess.rb
index 96335c2..3a69580 100644
--- a/test/ruby/testprocess.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

Associated revisions

Revision 39513
Added by Tomoyuki Chikanaga about 1 year ago

merge revision(s) 39179,39245: [Backport #7826]

the process maybe already finished
* test/ruby/test_process.rb (test_setsid): Added a workaround for
  MacOS X. Patch by nagachika. [Bug #7826] 

History

#1 Updated by Motohiro KOSAKI about 1 year ago

  • Status changed from Assigned to Closed

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

#2 Updated by Tomoyuki Chikanaga about 1 year ago

  • Status changed from Closed to Open
  • ruby -v changed from ruby 2.0.0dev (2012-12-30 trunk 38661) [x86_64-darwin10.8.0] to ruby 2.0.0dev (2013-02-11 trunk 39204) [x86_64-darwin10.8.0]

Sorry, I entered wrong ruby -v string. I encountered the fault with r39204.
So it may be another issue solved with r39179.

#3 Updated by Motohiro KOSAKI about 1 year ago

  • Status changed from Open to Assigned

#4 Updated by Motohiro KOSAKI about 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39245.
Tomoyuki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/ruby/testprocess.rb (testsetsid): Added a workaround for MacOS X. Patch by nagachika. [Bug #7826]

#5 Updated by Motohiro KOSAKI about 1 year ago

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.

#6 Updated by Tomoyuki Chikanaga about 1 year ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport200
  • Category deleted (test)
  • Status changed from Closed to Assigned
  • Assignee changed from Motohiro KOSAKI to Tomoyuki Chikanaga

r39179 and r39245 should be backported to 2.0.0.

#7 Updated by Tomoyuki Chikanaga about 1 year ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r39513.
Tomoyuki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 39179,39245: [Backport #7826]

the process maybe already finished
* test/ruby/test_process.rb (test_setsid): Added a workaround for
  MacOS X. Patch by nagachika. [Bug #7826] 

Also available in: Atom PDF