From 9f9608e6c570ecadf3db0112791b0f3e74a40335 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 5 Apr 2013 17:42:53 -0500 Subject: [PATCH] Allow pipe fd to be inherited under Ruby 2.0 --- Library/Homebrew/formula_installer.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 7f94b1d9ed..45f6841293 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -287,17 +287,24 @@ class FormulaInstaller # I'm guessing this is not a good way to do this, but I'm no UNIX guru ENV['HOMEBREW_ERROR_PIPE'] = write.to_i.to_s + args = %W[ + nice #{RUBY_PATH} + -W0 + -I #{File.dirname(__FILE__)} + -rbuild + -- + #{f.path} + ].concat(build_argv) + + # Ruby 2.0+ sets close-on-exec on all file descriptors except for + # 0, 1, and 2 by default, so we have to specify that we want the pipe + # to remain open in the child process. + args << { write => write } if RUBY_VERSION >= "2.0" + fork do begin read.close - exec 'nice', - RUBY_PATH, - '-W0', - '-I', Pathname.new(__FILE__).dirname, - '-rbuild', - '--', - f.path, - *build_argv + exec(*args) rescue Exception => e Marshal.dump(e, write) write.close