Skip allocating a pipe entirely in non-verbose mode
This commit is contained in:
parent
a211b61441
commit
34ea00783c
@ -508,24 +508,30 @@ class Formula
|
|||||||
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
||||||
mkdir_p(logd)
|
mkdir_p(logd)
|
||||||
|
|
||||||
rd, wr = IO.pipe
|
|
||||||
log = File.open(logfn, "w")
|
log = File.open(logfn, "w")
|
||||||
log.puts Time.now, "", cmd, args, ""
|
log.puts Time.now, "", cmd, args, ""
|
||||||
|
|
||||||
out = ARGV.verbose? ? wr : log
|
if ARGV.verbose?
|
||||||
|
rd, wr = IO.pipe
|
||||||
|
out = wr
|
||||||
|
else
|
||||||
|
out = log
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pid = fork do
|
pid = fork do
|
||||||
rd.close
|
if rd
|
||||||
log.close unless out == log
|
rd.close
|
||||||
|
log.close
|
||||||
|
end
|
||||||
exec_cmd(cmd, args, out, logfn)
|
exec_cmd(cmd, args, out, logfn)
|
||||||
end
|
end
|
||||||
wr.close
|
wr.close if wr
|
||||||
|
|
||||||
while buf = rd.gets
|
while buf = rd.gets
|
||||||
log.puts buf
|
log.puts buf
|
||||||
puts buf
|
puts buf
|
||||||
end if ARGV.verbose?
|
end if rd
|
||||||
|
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
|
|
||||||
@ -540,7 +546,7 @@ class Formula
|
|||||||
raise BuildError.new(self, cmd, args)
|
raise BuildError.new(self, cmd, args)
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
rd.close unless rd.closed?
|
rd.close if rd && !rd.closed?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user