Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
diff --git a/lib/nanoc3/cli/base.rb b/lib/nanoc3/cli/base.rb
--- a/lib/nanoc3/cli/base.rb
+++ b/lib/nanoc3/cli/base.rb
@@ -86,16 +86,24 @@ module Nanoc3::CLI
         end
       end
 
       @site
     end
 
     # Inherited from ::Cri::Base
     def run(args)
+      # Set exit handler
+      [ 'INT', 'TERM' ].each do |signal|
+        Signal.trap(signal) do
+          puts
+          exit!(0)
+        end
+      end
+
       super(args)
     rescue Interrupt => e
       exit(1)
     rescue StandardError, ScriptError => e
       print_error(e)
       exit(1)
     end
 
diff --git a/lib/nanoc3/cli/commands/watch.rb b/lib/nanoc3/cli/commands/watch.rb
--- a/lib/nanoc3/cli/commands/watch.rb
+++ b/lib/nanoc3/cli/commands/watch.rb
@@ -27,21 +27,16 @@ module Nanoc3::CLI::Commands
 
     def option_definitions
       []
     end
 
     def run(options, arguments)
       require 'fssm'
 
-      Signal.trap("INT") do
-        puts
-        exit
-      end
-
       @notifier = Notifier.new
 
       # Define rebuilder
       rebuilder = lambda do |base, relative|
         # Determine filename
         if base.nil? || relative.nil?
           filename = nil
         else