diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index a818cc5568..b237fc4470 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -32,6 +32,12 @@ at_exit do # can be inconvenient for the user. But we need to be safe. system "/usr/bin/sudo -k" + # The main Homebrew process expects to eventually see EOF on the error + # pipe in FormulaInstaller#build. However, if any child process fails to + # terminate (i.e, fails to close the descriptor), this won't happen, and + # the installer will hang. Set close-on-exec to prevent this. + # Whether it is *wise* to launch daemons from formulae is a separate + # question altogether. if ENV['HOMEBREW_ERROR_PIPE'] require 'fcntl' IO.new(ENV['HOMEBREW_ERROR_PIPE'].to_i, 'w').fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)