lib/backticks/command.rb in backticks-1.0.3 vs lib/backticks/command.rb in backticks-1.0.4
- old
+ new
@@ -68,10 +68,15 @@
def success?
join
status.success?
end
+ # Determine whether output has been exhausted.
+ def eof?
+ @stdout.eof? && @stderr.eof?
+ end
+
# Provide a callback to monitor input and output in real time. This method
# saves a reference to block for later use; whenever the command generates
# output or receives input, the block is called back with the name of the
# stream on which I/O occurred and the actual data that was read or written.
# @yield
@@ -98,9 +103,10 @@
until (t = Time.now) >= tf
capture(tf-t)
res = Process.waitpid(@pid, Process::WNOHANG)
if res
@status = $?
+ capture(nil) until eof?
return self
end
end
return nil