Fix double newline after Interrupt

Seems to be an issue with Ruby system() call doing a double fork.
This commit is contained in:
Max Howell 2009-09-05 20:46:07 +01:00
parent 64e767155a
commit 680e201923
3 changed files with 10 additions and 6 deletions

View File

@ -23,7 +23,7 @@
#
class ExecutionError <RuntimeError
def initialize cmd, args=[]
super "#{cmd} #{args*' '}"
super "Failure while executing: #{cmd} #{args*' '}"
end
end
class BuildError <ExecutionError

View File

@ -64,11 +64,12 @@ end
# Kernel.system but with exceptions
def safe_system cmd, *args
puts "#{cmd} #{args*' '}" if ARGV.verbose?
execd=Kernel.system cmd, *args
# somehow Ruby doesn't handle the CTRL-C from another process -- WTF!?
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 os
# still 2 so we raise our own interrupt
raise Interrupt, cmd if $?.termsig == 2
raise ExecutionError.new(cmd, args) unless execd and $? == 0
raise ExecutionError.new(cmd, args) unless exec_success and $?.success?
end
def curl url, *args

View File

@ -210,7 +210,10 @@ rescue UsageError
rescue SystemExit
ohai "Kernel.exit" if ARGV.verbose?
rescue Interrupt => e
puts # seemingly a newline is typical
# puts # seemingly a newline is typical
# Above is now commented out because the system() call forks and then forks
# again, so there are two of "us" so we get two exceptions raising and thus
# two newlines, which buggers up the shell. FIXME!
exit 130
rescue SystemCallError, RuntimeError => e
if ARGV.debug?