Exit status of process started with open()
What is the exist sta开发者_如何学Pythontus of a process opened with open() e.g.:
f = open("|#{cmd}", 'r')
while char = f.getc
do something ...
end
f.????
$?
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
精彩评论