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

[macOS] POSIX::Spawn.system stale $? for missing commands #82

Open
felixbuenemann opened this issue May 16, 2017 · 1 comment
Open

[macOS] POSIX::Spawn.system stale $? for missing commands #82

felixbuenemann opened this issue May 16, 2017 · 1 comment

Comments

@felixbuenemann
Copy link

If the command run by POSIX::Spawn.system fails to execute because it was not found (Errno:ENOENT raised by POSIX::Spawn.spawn), the content of the $? global variable is not updated on macOS 10.12.14, which differs from the behavior of Kernel.system which sets $? to an Instance of Process::Status with exitstatus 127.

macOS 10.12.4:

$ ruby -v
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-darwin16]
$ irb
2.2.6 :001 > $?
 => nil
2.2.6 :002 > Kernel.system "foo"
 => nil
2.2.6 :003 > $?
 => #<Process::Status: pid 20175 exit 127>
2.2.6 :004 >
$ irb -r posix/spawn
2.2.6 :001 > $?
 => nil
2.2.6 :002 > POSIX::Spawn.system "foo"
 => false
2.2.6 :003 > $?
 => nil
2.2.6 :004 >

Linux (Debian Jessie):

Status: Downloaded newer image for ruby:2.2
root@0cd5cc5c4feb:/# gem install --no-document posix-spawn
Fetching: posix-spawn-0.3.13.gem (100%)
Building native extensions.  This could take a while...
Successfully installed posix-spawn-0.3.13
1 gem installed
root@0cd5cc5c4feb:/# ruby -v
ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-linux]
root@0cd5cc5c4feb:/# irb
irb(main):001:0>
root@0cd5cc5c4feb:/# irb
irb(main):001:0> $?
=> nil
irb(main):002:0> Kernel.system "foo"
=> nil
irb(main):003:0> $?
=> #<Process::Status: pid 38 exit 127>
irb(main):004:0>
root@0cd5cc5c4feb:/# irb -r posix/spawn
irb(main):001:0> $?
=> nil
irb(main):002:0> POSIX::Spawn.system "foo"
=> false
irb(main):003:0> $?
=> #<Process::Status: pid 41 exit 127>
irb(main):004:0>

Note that $? stays nil in the POSIX::Spawn case on macOS.

This issue is loosely related to and was extracted from #81.

@felixbuenemann
Copy link
Author

felixbuenemann commented May 16, 2017

I have also tested this with ruby 2.4.1 on both Linux and macOS, but the results are the same as with ruby 2.2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant