Bug #7789

test_setsid fails for OpenBSD

Added by George Koehler about 1 year ago. Updated about 1 year ago.

[ruby-core:51889]
Status:Closed
Priority:Normal
Assignee:Motohiro KOSAKI
Category:core
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2013-02-06 trunk 39081) [x86_64-openbsd5.2] Backport:

Description

=begin
TestProcess#test_setsid always fails because OpenBSD doesn't allow Process::getsid(pid) when the pid is in a different session. Quoting man getsid, "[EPERM] The current process and the process pid are not in the same session."

How to reproduce:

$ make test-all TESTS='ruby/testprocess.rb -n testsetsid'
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -ansi -std=iso9899:199409
XCFLAGS = -include ruby/config.h -include ruby/missing.h -DFORTIFYSOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBYEXPORT -fPIE
CPPFLAGS = -I/usr/local/include -I. -I.ext/include/x86
64-openbsd5.2 -I../include -I..
DLDFLAGS = -fstack-protector -pie

SOLIBS =
./miniruby -I../lib -I. -I.ext/common ../tool/runruby.rb --extout=.ext -- --disable-gems "../test/runner.rb" --ruby="./miniruby -I../lib -I. -I.ext/common ../tool/runruby.rb --extout=.ext -- --disable-gems" ruby/testprocess.rb -n testsetsid
Run options: "--ruby=./miniruby -I../lib -I. -I.ext/common ../tool/runruby.rb --extout=.ext -- --disable-gems" -n test_setsid

# Running tests:

[1/1] TestProcess#testsetsid = 3.04 s
1) Error:
test
setsid(TestProcess):
Errno::EPERM: Operation not permitted
/home/kernigh/park/ruby/test/ruby/testprocess.rb:1589:in getsid'
/home/kernigh/park/ruby/test/ruby/test_process.rb:1589:in
block in test
setsid'
/home/kernigh/park/ruby/test/ruby/testprocess.rb:1578:in popen'
/home/kernigh/park/ruby/test/ruby/test_process.rb:1578:in
test
setsid'

Finished tests in 3.050209s, 0.3278 tests/s, 0.3278 assertions/s.
1 tests, 1 assertions, 0 failures, 1 errors, 0 skips

ruby -v: ruby 2.0.0dev (2013-02-06 trunk 39081) [x86_64-openbsd5.2]
*** Error code 1

Stop in /home/kernigh/park/ruby/build (line 977 of Makefile).

The only fix is to skip the Process::getsid(pid) in the test. I wrote a patch for this. My patch does not call the skip method, because I was not sure how to call it. I don't want to skip the whole test.

While I am looking at this test, I see that it calls (({Process.kill(:KILL, io.pid)})) but never reaps the zombie process. Shouldn't it call (({Process.wait(io.pid)})) after that?

=end

setsid-openbsd.diff Magnifier - skip the Process::getsid(pid) in the test (815 Bytes) George Koehler, 02/06/2013 08:31 AM

Associated revisions

Revision 39097
Added by Motohiro KOSAKI about 1 year ago

  • test/ruby/testprocess.rb (testsetsid): skip when platform is OpenBSD. Contributed from George Koehler. [Bug #7789]

History

#1 Updated by Motohiro KOSAKI about 1 year ago

  • Category set to core
  • Status changed from Open to Assigned
  • Assignee set to Motohiro KOSAKI
  • Target version set to 2.0.0

#2 Updated by Motohiro KOSAKI about 1 year ago

The only fix is to skip the Process::getsid(pid) in the test. I wrote a patch for this.

OK. I agree with skipping test. But I would like to just skip instead of your approach.

While I am looking at this test, I see that it calls Process.kill(:KILL, io.pid) but never reaps the zombie process. Shouldn't it call > Process.wait(io.pid) after that?

Yeah! You are right. I'll fix this.

#3 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 r39097.
George, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/ruby/testprocess.rb (testsetsid): skip when platform is OpenBSD. Contributed from George Koehler. [Bug #7789]

Also available in: Atom PDF