tags:

views:

19

answers:

1

What is the exist status of a process opened with open() e.g.:

f = open("|#{cmd}", 'r')
while char = f.getc
  do something ...
end
f.????
+2  A: 

$? will contain the exit status after you have closed f. e.g.

irb(main):024:0> f = open("|#{cmd}", "r")
=> #<IO:0x2d7e9dc>
# read from f here
irb(main):025:0> f.close
=> nil
irb(main):026:0> $?
=> #<Process::Status: pid=3576,exited(0)>
irb(main):027:0> $?.exitstatus
=> 0
mikej
ahh damn i had something like this, but it did not work because i did not .close :DTanks!!
grosser