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
commitc2f05cfb711401a498d494e9dcc90016e9b168a7 (patch)
tree8695700d53ed7380d6d9e01d921f9efe7732c176 /Library
parentec39148c04cc8c8e47f882bc87a6687ea94e4370 (diff)
downloadbrew-c2f05cfb711401a498d494e9dcc90016e9b168a7.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