aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJeff Clites2012-07-03 15:32:36 -0700
committerJack Nagel2012-07-08 02:35:26 -0500
commitc24260e271e856f6354cb5981ac3839283ff8750 (patch)
treeebf6fe9c085287c22f35479eca7d97148d56ca28 /Library
parent4089d8733840ec1f5a59ff57bcd08d0e32478be6 (diff)
downloadhomebrew-c24260e271e856f6354cb5981ac3839283ff8750.tar.bz2
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 <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Homebrew/build.rb12
1 files changed, 7 insertions, 5 deletions
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