Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open3 fails with varying signals on 9.0.0.0.pre1 #2494

Closed
philr opened this issue Jan 21, 2015 · 4 comments
Closed

Open3 fails with varying signals on 9.0.0.0.pre1 #2494

philr opened this issue Jan 21, 2015 · 4 comments

Comments

@philr
Copy link
Contributor

philr commented Jan 21, 2015

I am using jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-21 ac0d512 OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_65-b32 +jit [linux-amd64].

I am executing processes using Open3. Instead of receiving the expected exit status, I am instead seeing a signal raised:

jruby-head :002 > Open3.popen3('ruby', '-e', 'exit true') {|i,o,e,t| t.value}
 => #<Process::Status: pid 21796 signal 36> 
jruby-head :003 > Open3.popen3('ruby', '-e', 'exit true') {|i,o,e,t| t.value}
 => #<Process::Status: pid 21817 signal 57> 

The signal number increases by about 22 with each execution before wrapping around at around 127.

With JRuby 1.7.18, I get the expected result:

jruby-1.7.18 :002 > Open3.popen3('ruby', '-e', 'exit true') {|i,o,e,t| t.value}
 => #<Process::Status: pid=18784,exited(0)> 

The capture3 method fails in the same way:

jruby-head :004 > Open3.capture3('ruby', '-e', 'i=STDIN.read; print i+"o"; STDOUT.flush; STDERR.print i+"e"', :stdin_data=>"i")
 => ["io", "ie", #<Process::Status: pid 21839 signal 79>] 

The above examples are based on code from test/mri/test_open3.rb. If I run test/mri/test_open3.rb, I get 16 test failures.

@headius
Copy link
Member

headius commented Jan 21, 2015

Seems specific to how open3 is doing its subprocess launching. If I use system the exit status looks right:

~/projects/jruby $ jruby -ropen3 -e "5.times { p Open3.popen3('ruby', '-e', 'exit true') {|i,o,e,t| t.value} }"
#<Process::Status: pid 36648 signal 40>
#<Process::Status: pid 36662 signal 54>
#<Process::Status: pid 36676 signal 68>
#<Process::Status: pid 36692 signal 84>
#<Process::Status: pid 36706 signal 98>

~/projects/jruby $ jruby -ropen3 -e "5.times { system('ruby', '-e', 'exit true'); p \$? }"
#<Process::Status: pid 36729 exit 0>
#<Process::Status: pid 36743 exit 0>
#<Process::Status: pid 36757 exit 0>
#<Process::Status: pid 36771 exit 0>
#<Process::Status: pid 36785 exit 0>

@headius
Copy link
Member

headius commented Jan 22, 2015

Problem is in Process.detach...it's not using the right value for exit code:

$ jruby -e "process = spawn('ruby', '-e', 'exit true'); thread = Process.detach(process); p thread.value"
#<Process::Status: pid 37181 signal 61>

@headius
Copy link
Member

headius commented Jan 22, 2015

Please confirm with JRuby master. Thanks for the report...this fix made a bunch of other tests start passing too.

@headius headius added this to the 9.0.0.0.pre2 milestone Jan 22, 2015
@headius headius self-assigned this Jan 22, 2015
@philr
Copy link
Contributor Author

philr commented Jan 22, 2015

I can confirm that this is now fixed. Thank you @headius.

Kris-LIBIS pushed a commit to libis/LIBIS_Tools that referenced this issue Oct 5, 2015
- force usage of jruby-9.0.1.0 as with 9.0.0.0 Travis seems to use the pre1 version which has a known bug in popen3: jruby/jruby#2494
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants