# File lib/popen4.rb, line 45 def self.popen4(command, mode = "t") # :yields: stdout, stderr, stdin, pid err_output = nil Open4.popen4(command, mode) do |stdin,stdout,stderr,pid| yield stdout, stderr, stdin, pid # On windows we will always get an exit status of 3 unless # we read to the end of the streams so we do this on all platforms # so that our behavior is always the same. stdout.read unless stdout.eof? # On windows executing a non existent command does not raise an error # (as in unix) so on unix we return nil instead of a status object and # on windows we try to determine if we couldn't start the command and # return nil instead of the Process::Status object. stderr.rewind err_output = stderr.read end return $? end