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 class ExecutionError <RuntimeError
def initialize cmd, args=[] def initialize cmd, args=[]
super "#{cmd} #{args*' '}" super "Failure while executing: #{cmd} #{args*' '}"
end end
end end
class BuildError <ExecutionError class BuildError <ExecutionError

View File

@ -64,11 +64,12 @@ end
# Kernel.system but with exceptions # Kernel.system but with exceptions
def safe_system cmd, *args def safe_system cmd, *args
puts "#{cmd} #{args*' '}" if ARGV.verbose? puts "#{cmd} #{args*' '}" if ARGV.verbose?
exec_success=Kernel.system cmd, *args
execd=Kernel.system cmd, *args # some tools, eg. tar seem to confuse ruby and it doesn't propogate the
# somehow Ruby doesn't handle the CTRL-C from another process -- WTF!? # 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 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 end
def curl url, *args def curl url, *args

View File

@ -210,7 +210,10 @@ rescue UsageError
rescue SystemExit rescue SystemExit
ohai "Kernel.exit" if ARGV.verbose? ohai "Kernel.exit" if ARGV.verbose?
rescue Interrupt => e 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 exit 130
rescue SystemCallError, RuntimeError => e rescue SystemCallError, RuntimeError => e
if ARGV.debug? if ARGV.debug?