Commit 5f8fbd34 authored by Phil Dibowitz's avatar Phil Dibowitz
Browse files

[11] Don't catch SIGTERM if not in daemon mode

This doens't make sense if not in daemon mode.
parent 932d7656
......@@ -3,5 +3,6 @@
## Unreleased
## Last Release: 11.12.0 RC1 (03/31/2014)
* SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172)
http://www.getchef.com/blog/2014/03/31/release-candidates-chef-client-11-12-0-10-32-0/
......@@ -6,3 +6,4 @@ Example Contribution:
-->
# Chef Client Contributions:
* **jaymzh**: SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172)
......@@ -8,3 +8,9 @@ Details about the thing that changed that needs to get included in the Release N
-->
# Chef Client Release Notes:
#### Signal Regression Fix
CHEF-1761 introduced a regression for signal handling when not in daemon mode
(see CHEF-5172). Chef will now, once again, exit immediately on SIGTERM if it
is not in daemon mode, otherwise it will complete it's current run before
existing.
......@@ -295,9 +295,12 @@ class Chef::Application::Client < Chef::Application
SELF_PIPE[1].putc(IMMEDIATE_RUN_SIGNAL) # wakeup master process from select
end
trap("TERM") do
Chef::Log.info("SIGTERM received, exiting gracefully")
SELF_PIPE[1].putc(GRACEFUL_EXIT_SIGNAL)
# see CHEF-5172
if Chef::Config[:daemonize] || Chef::Config[:interval]
trap("TERM") do
Chef::Log.info("SIGTERM received, exiting gracefully")
SELF_PIPE[1].putc(GRACEFUL_EXIT_SIGNAL)
end
end
end
......
......@@ -128,8 +128,10 @@ end
describe Chef::Application::Client, "run_application", :unix_only do
before(:each) do
Chef::Config[:daemonize] = true
@pipe = IO.pipe
@app = Chef::Application::Client.new
Chef::Daemon.stub(:daemonize).and_return(true)
@app.stub(:run_chef_client) do
@pipe[1].puts 'started'
sleep 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment