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

Unexpected value for $?.exitstatus when process exited successfully #4361

javierhonduco opened this issue Dec 6, 2016 · 4 comments


Copy link


  • jruby (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit Server VM 24.65-b04 on 1.7.0_67-b01 +jit [darwin-x86_64]
  • Darwin 16.1.0 Darwin Kernel Version 16.1.0: Wed Oct 19 20:31:56 PDT 2016; root:xnu-3789.21.4~4/RELEASE_X86_64 x86_64

There's nothing special (gems or whatsoever) running on this machine.

Expected Behavior

When running this snippet of code:

system "exit 0"
puts "ruby_success=#{$?.success?} exit_code=#{$?.exitstatus}"

MRI (2.3.1) outputs
ruby_success=true exit_code=0

Actual Behavior

Unfortunately this is the output I'm getting under the JRuby version mentioned above:

ruby_success=false exit_code=127

I don't know if this is expected as per JRuby system's implementation, sorry if that's the case!

Copy link

Same on

$ rvm jruby- do ruby -e 'system "exit 0"; puts "ruby_success=#{$?.success?} exit_code=#{$?.exitstatus}"'
ruby_success=false exit_code=127

Copy link

headius commented Dec 6, 2016

Looks like we're not doing the right masking of the exit status.

Copy link

headius commented Dec 6, 2016

Ok, so here's the problem. We do the correct masking; however in this case the system call is actually failing. It tries to find an executable exit command, and seeing none it bails out with exit code of 127. MRI must be doing some extra logic here to know it needs to run with sh -c.

@headius headius closed this as completed in 69da0af Dec 6, 2016
@enebo enebo added this to the JRuby milestone Dec 6, 2016
Copy link
Contributor Author

javierhonduco commented Dec 6, 2016

Thanks a lot guys! You were super-fast!


kares pushed a commit that referenced this issue Dec 7, 2016
* Add regression test for shell exit (#4361)

Adds a regression test for 69da0af reported in this issue #4361.

* Update test_kernel.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants