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 <source@sharpsteen.net>
This commit is contained in:
Charlie Sharpsteen 2012-07-06 12:56:18 -08:00
parent f17429f842
commit 8a0c94d4e0

View File

@ -109,8 +109,10 @@ end
# prints no output # prints no output
def quiet_system cmd, *args def quiet_system cmd, *args
Homebrew.system(cmd, *args) do Homebrew.system(cmd, *args) do
$stdout.close # Redirect output streams to `/dev/null` instead of closing as some programs
$stderr.close # will fail to execute if they can't write to an open stream.
$stdout.reopen('/dev/null')
$stderr.reopen('/dev/null')
end end
end end