Don't use Kernel.system much
It just seems to behave strangely with SIGINT. Eg. SIGINT causes tar to exit, but the SIGINT is ignored by our process. This is not the case when used with curl.
This commit is contained in:
parent
590f64e302
commit
1da26d89ea
@ -60,7 +60,7 @@ class FormulaInstaller
|
||||
exit! 1
|
||||
end
|
||||
end
|
||||
ignore_interrupts do
|
||||
ignore_interrupts do # because child proc will get it and marshall it back
|
||||
write.close
|
||||
Process.wait
|
||||
data = read.read
|
||||
|
||||
@ -30,6 +30,24 @@ MACOS_VERSION=10.6
|
||||
Dir.chdir HOMEBREW_PREFIX
|
||||
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||
|
||||
# for some reason our utils.rb safe_system behaves completely differently
|
||||
# during these tests. This is worrying for sure.
|
||||
def safe_system *args
|
||||
Kernel.system *args
|
||||
end
|
||||
|
||||
class ExecutionError <RuntimeError
|
||||
attr :status
|
||||
|
||||
def initialize cmd, args=[], status=nil
|
||||
super "Failure while executing: #{cmd} #{args*' '}"
|
||||
@status = status
|
||||
end
|
||||
end
|
||||
|
||||
class BuildError <ExecutionError
|
||||
end
|
||||
|
||||
require 'test/unit' # must be after at_exit
|
||||
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
|
||||
ARGV.extend(HomebrewArgvExtension)
|
||||
|
||||
@ -69,27 +69,29 @@ def pretty_duration s
|
||||
end
|
||||
|
||||
def interactive_shell
|
||||
pid=fork
|
||||
if pid.nil?
|
||||
fork do
|
||||
# TODO make the PS1 var change pls
|
||||
#brown="\[\033[0;33m\]"
|
||||
#reset="\[\033[0m\]"
|
||||
#ENV['PS1']="Homebrew-#{HOMEBREW_VERSION} #{brown}\W#{reset}\$ "
|
||||
exec ENV['SHELL']
|
||||
end
|
||||
Process.wait pid
|
||||
raise SystemExit, "Aborting due to non-zero exit status" if $? != 0
|
||||
Process.wait
|
||||
unless $?.success?
|
||||
puts "Aborting due to non-zero exit status"
|
||||
exit $?
|
||||
end
|
||||
end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
def safe_system cmd, *args
|
||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||
exec_success = Kernel.system cmd, *args
|
||||
# some tools, eg. tar seem to confuse ruby and it doesn't propogate the
|
||||
# CTRL-C interrupt to us too, so execution continues, but the exit code is
|
||||
# still 2 so we raise our own interrupt
|
||||
raise Interrupt, cmd if $?.termsig == 2
|
||||
raise ExecutionError.new(cmd, args, $?) unless exec_success
|
||||
fork do
|
||||
trap("EXIT") {} # no bt on exit from this short-lived fork
|
||||
exit! 1 unless exec(cmd, *args)
|
||||
end
|
||||
Process.wait
|
||||
raise ExecutionError.new(cmd, args, $?) unless $?.success?
|
||||
end
|
||||
|
||||
def curl *args
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user