lib/autobuild/subcommand.rb in autobuild-1.6.2.b12 vs lib/autobuild/subcommand.rb in autobuild-1.6.2.rc1

- old
+ new

@@ -127,10 +127,11 @@ end end CONTROL_COMMAND_NOT_FOUND = 1 CONTROL_UNEXPECTED = 2 + CONTROL_INTERRUPT = 3 def self.run(target, phase, *command) STDOUT.sync = true input_streams = [] options = Hash.new @@ -206,15 +207,16 @@ cread, cwrite = IO.pipe # to control that exec goes well cwrite.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) pid = fork do - if options[:working_directory] && (options[:working_directory] != Dir.pwd) - Dir.chdir(options[:working_directory]) - end - logfile.puts "in directory #{Dir.pwd}" begin + if options[:working_directory] && (options[:working_directory] != Dir.pwd) + Dir.chdir(options[:working_directory]) + end + logfile.puts "in directory #{Dir.pwd}" + cwrite.sync = true if Autobuild.nice Process.setpriority(Process::PRIO_PROCESS, 0, Autobuild.nice) end @@ -233,14 +235,17 @@ end exec(*command) rescue Errno::ENOENT cwrite.write([CONTROL_COMMAND_NOT_FOUND].pack('I')) - raise + exit(100) + rescue Interrupt + cwrite.write([CONTROL_INTERRUPT].pack('I')) + exit(100) rescue ::Exception cwrite.write([CONTROL_UNEXPECTED].pack('I')) - raise + exit(100) end end # Feed the input if !input_streams.empty? @@ -263,9 +268,11 @@ if value # An error occured value = value.unpack('I').first if value == CONTROL_COMMAND_NOT_FOUND raise Failed.new, "command '#{command.first}' not found" + elsif value == CONTROL_INTERRUPT + raise Interrupt, "command '#{command.first}': interrupted by user" else raise Failed.new, "something unexpected happened" end end