about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/unicorn.rb4
-rw-r--r--test/exec/test_exec.rb16
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 4465109..bb4054a 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -521,8 +521,8 @@ module Unicorn
               reopen_logs or exit(alive ? 1 : 0)
             end
           end
-        rescue SystemExit => e
-          exit(e.status)
+        rescue SignalException, SystemExit => e
+          raise e
         rescue Object => e
           if alive
             logger.error "Unhandled listen loop exception #{e.inspect}."
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb
index 596ab88..8780da0 100644
--- a/test/exec/test_exec.rb
+++ b/test/exec/test_exec.rb
@@ -72,6 +72,22 @@ end
     end
   end
 
+  def test_exit_signals
+    %w(INT TERM QUIT).each do |sig|
+      File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
+      pid = xfork { redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port") } }
+      wait_master_ready("test_stderr.#{pid}.log")
+      status = nil
+      assert_nothing_raised do
+        Process.kill(sig, pid)
+        pid, status = Process.waitpid2(pid)
+      end
+      reaped = File.readlines("test_stderr.#{pid}.log").grep(/reaped/)
+      assert_equal 1, reaped.size
+      assert status.exited?
+    end
+  end
+
   def test_basic
     File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
     pid = fork do