From c2f05cfb711401a498d494e9dcc90016e9b168a7 Mon Sep 17 00:00:00 2001 From: Jeff Clites Date: Tue, 3 Jul 2012 15:32:36 -0700 Subject: Prevent error pipe object from being finalized When the first error pipe object is finalized, the underlying file descriptor is closed, breaking the pipe between the build script and the main Homebrew process. Keep a reference to this object so it isn't closed. Signed-off-by: Jack Nagel --- Library/Homebrew/build.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index 634500e8b..72628ac46 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -10,6 +10,8 @@ at_exit do # the whole of everything must be run in at_exit because the formula has to # be the run script as __END__ must work for *that* formula. + error_pipe = nil + begin raise $! if $! # an exception was already thrown when parsing the formula @@ -35,15 +37,15 @@ at_exit do # 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) + error_pipe = IO.new(ENV['HOMEBREW_ERROR_PIPE'].to_i, 'w') + error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end install(Formula.factory($0)) rescue Exception => e - if ENV['HOMEBREW_ERROR_PIPE'] - pipe = IO.new(ENV['HOMEBREW_ERROR_PIPE'].to_i, 'w') - Marshal.dump(e, pipe) - pipe.close + unless error_pipe.nil? + Marshal.dump(e, error_pipe) + error_pipe.close exit! 1 else onoe e -- cgit v1.2.3