From 8a0c94d4e01361617eaacae6f26348ad59410d4d Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Fri, 6 Jul 2012 12:56:18 -0800 Subject: [PATCH] quiet_system: Dump to /dev/null instead of closing Some programs fail where they would otherwise succeed if stdout or stderr is closed. For example, using mpicc from the mpich2 formula: quiet_system 'mpicc', '--version' Fails with: LLVM ERROR: IO failure on output stream. While system 'mpicc', '--version' Succeeds. Closes Homebrew/homebrew#13253. Signed-off-by: Charlie Sharpsteen --- Library/Homebrew/utils.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 2af1072c4c..4099c48259 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -109,8 +109,10 @@ end # prints no output def quiet_system cmd, *args Homebrew.system(cmd, *args) do - $stdout.close - $stderr.close + # Redirect output streams to `/dev/null` instead of closing as some programs + # will fail to execute if they can't write to an open stream. + $stdout.reopen('/dev/null') + $stderr.reopen('/dev/null') end end