PTY with wait incorrectly sets exit status for exit command
Realizing this is irrelevant under normal usage, it appears wait on a PTY process does not set the correct exit status for an 'exit' command. For example:
PTY.spawn("exit 8") do |r,w,pid| Process.wait(pid) end $?.exitstatus # => 1
Incidentally 'system' also appears to suffer from this unexpected behavior.
system "exit 8" $?.exitstatus # => 127
I think that either the most obvious exit status (8) should be set by both PTY and system or, if for some reason that can't happen then the behavior should be consistent between them. A test case is attached.
Note that on 1.9.3-preview1 you get different behavior. The PTY code results in "Errno::ENOENT: No such file or directory - exit 8".
Also, a similar inconsistency happens with an empty string (although I don't know what the correct behavior is in this case):
PTY.spawn("") do |r,w,pid| Process.wait(pid) end $?.exitstatus # => 1 system "" $?.exitstatus # => 127
I know, I know... these are edge cases! I won't try to argue calling PTY with an exit command or empty string is normal, but it came up in exploration while trying to make some example code.