require 'timeout'
a = IO.popen("command")
# later
begin
Timeout::timeout(0.01) { Process.wait(a.pid) }
puts 'shows signs of being dead'
rescue TimeoutError
puts 'probably still alive'
end
September 1, 2009
how to determine if a subprocess has died in ruby
1 Comment »
RSS feed for comments on this post. TrackBack URL
this is for windows–for Linux you can use Process::WNOHANG [or something like that] splendidly to see if it is dead or not.
Comment by rogerdpack — September 2, 2009 @ 12:53 am