Re: fork with exit [some integer] seems to not change exitstatus in Process.wait2, ruby 2.2.4

Kelly Felkins <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAGHx4SjCEo7fd5B_saAKUf4o21VW1mEnDwUwqHaYpz9Wy4=VmQ@mail.gmail.com>
Thanks Eric and Marvin. I moved it to a script and I get the expected
results.

Here's the script and the results.

Thanks again.

-Kelly

script:
-------------

#!/usr/bin/env ruby
puts "ruby version: #{RUBY_VERSION}"

pid = fork do
  sleep 1
  exit 55
end

returned_pid, status = Process.wait2

puts "pid: #{pid}, returned_pid: #{returned_pid}, status:
#{status.inspect}, exitstatus: #{status.exitstatus}"

pid = fork do
  sleep 1
  exit 0
end

returned_pid, status = Process.wait2

puts "pid: #{pid}, returned_pid: #{returned_pid}, status:
#{status.inspect}, exitstatus: #{status.exitstatus}"

--------


output

------------

$ ./test.rb
ruby version: 2.4.1
pid: 91480, returned_pid: 91480, status: #<Process::Status: pid 91480
exit 55>, exitstatus: 55
pid: 91481, returned_pid: 91481, status: #<Process::Status: pid 91481
exit 0>, exitstatus: 0

---------------


On Mon, Jan 7, 2019 at 3:41 AM Marvin Gülker <[email protected]>
wrote:

> Am 06. Januar 2019 um 16:42 Uhr -0800 schrieb Kelly Felkins:
> > I'm attempting to retrieve the exit status of child processes. So far, no
> > matter how the child process exists, wait2 status only has a 1 for
> > exitstatus.
>
> Try this outside IRB as a standalone script. Eric is most likely right
> that it's an IRB-specific problem you're running into.
>
> --
> Blog: https://mg.guelker.eu
> PGP/GPG ID: F1D8799FBCC8BC4F
>
> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
-- 
Join the conversation in your neighborhood.
Register for Oakland's homegrown neighbor network, JustMyNeighbors.com

https://www.justmyneighbors.com/register


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.