diff options
| author | Jack Nagel | 2012-05-08 21:40:55 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-05-23 17:43:14 -0500 |
| commit | d9fe48cf543b7d1594dd491b27ab578acf237186 (patch) | |
| tree | 5f72e5856b2d1904a997b9713694ce1a09342cce /Library | |
| parent | 01bcf58e6a290f66d7eaaea5adb295ca3aeb2a44 (diff) | |
| download | brew-d9fe48cf543b7d1594dd491b27ab578acf237186.tar.bz2 | |
Set close-on-exec on the error pipe
We use a pipe to marshal exceptions from the build script back to the
main Homebrew process; the associated file descriptor is stored in an
environment variable so that the script can figure out which descriptor
to use after being exec'd.
However, any child processes of the build script inherit this
descriptor (i.e. anything spawned via "system" by the formula during
installation). Normally this is not an issue, but if a formula executes
a long-running process such as a daemon, the main Homebrew process will
never see EOF on the error pipe because the daemon still has an open
descriptor.
We can fix this while preserving current behavior by setting the
close-on-exec flag on the build script's error pipe descriptor.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Homebrew/build.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index ab1a44e6e..f72633ffa 100755 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -32,6 +32,11 @@ at_exit do # can be inconvenient for the user. But we need to be safe. system "/usr/bin/sudo -k" + if ENV['HOMEBREW_ERROR_PIPE'] + require 'fcntl' + IO.new(ENV['HOMEBREW_ERROR_PIPE'].to_i, 'w').fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) + end + install(Formula.factory($0)) rescue Exception => e if ENV['HOMEBREW_ERROR_PIPE'] |
