diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/external_command.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/external_command.rb b/lib/external_command.rb index de8bfc11e..96292854f 100644 --- a/lib/external_command.rb +++ b/lib/external_command.rb @@ -104,20 +104,24 @@ class ExternalCommand @fhs = {@out_read => @out, @err_read => @err, @fin_read => @fin} while @fin.empty? - r = read_data - if r.nil? + ok = read_data + if !ok raise "select() timed out even with a nil (infinite) timeout" end end + while read_data(0) + # Pull out any data that’s left in the pipes + end + Process::waitpid(@pid) @status = @fin.to_i @out_read.close @err_read.close end - def read_data() - ready_array = IO.select(@fhs.keys, [], [], nil) + def read_data(timeout=nil) + ready_array = IO.select(@fhs.keys, [], [], timeout) return false if ready_array.nil? ready_array[0].each do |fh| begin |