silent_system(*command)
public
Invokes system, but silences all output.
# File lib/rubygems/util.rb, line 73
def self.silent_system(*command)
opt = {:out => IO::NULL, :err => [:child, :out]}
if Hash === command.last
opt.update(command.last)
cmds = command[0...-1]
else
cmds = command.dup
end
return system(*(cmds << opt))
rescue TypeError
@silent_mutex ||= Mutex.new
@silent_mutex.synchronize do
begin
stdout = STDOUT.dup
stderr = STDERR.dup
STDOUT.reopen IO::NULL, 'w'
STDERR.reopen IO::NULL, 'w'
return system(*command)
ensure
STDOUT.reopen stdout
STDERR.reopen stderr
stdout.close
stderr.close
end
end
end