summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2014-04-01 10:41:44 -0700
committerPhil Dibowitz <phil@ipom.com>2014-04-01 10:41:44 -0700
commit3036482c1f7b8010249dea81cfcac01662736788 (patch)
tree6f0c2fe379d846da4083767a45251e6ae2a5e696
parentcbe9deb2df26cea9955550764c4902fbf190f6f8 (diff)
parent586df54abfadd3c3cc830d784d5e793fa7bf55e3 (diff)
downloadchef-3036482c1f7b8010249dea81cfcac01662736788.tar.gz
Merge pull request #1314 from jaymzh/fixsignals
[10-stable] Don't trap TERM if not in daemon mode
-rw-r--r--CHANGELOG.md1
-rw-r--r--CONTRIBUTIONS.md1
-rw-r--r--RELEASE_NOTES.md2
-rw-r--r--chef/lib/chef/application/client.rb11
-rw-r--r--chef/spec/unit/application/client_spec.rb3
5 files changed, 12 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e90b4506de..4d02e71bbb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
* Service Provider for MacOSX now supports `enable` and `disable`
* Chef now gracefully handles corrupted cache files.
+* SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172)
## Last Release: 10.30.4 (02/18/2014)
diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md
index d0b917eef7..ade732cbe9 100644
--- a/CONTRIBUTIONS.md
+++ b/CONTRIBUTIONS.md
@@ -8,3 +8,4 @@ Example Contribution:
* **jaymzh**: Service Provider for MacOSX now supports `enable` and `disable`
* **jaymzh**: Chef now gracefully handles corrupted cache files.
+* **jaymzh**: SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 7e770d7dfe..870392fc16 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -9,6 +9,6 @@ Details about the thing that changed that needs to get included in the Release N
# Chef Client 10.x Release Notes:
* Service Provider for MacOSX now supports `enable` and `disable`
-
+* SIGTERM will now terminate non-daemon mode Chef runs (CHEF-5172)
# Chef Client 10.x Breaking Changes:
diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb
index 901a2d79ab..f491111480 100644
--- a/chef/lib/chef/application/client.rb
+++ b/chef/lib/chef/application/client.rb
@@ -256,10 +256,13 @@ class Chef::Application::Client < Chef::Application
SELF_PIPE[1].putc('.') # wakeup master process from select
end
- trap("TERM") do
- Chef::Log.info("SIGTERM received, exiting gracefully")
- @exit_gracefully = true
- SELF_PIPE[1].putc('.')
+ # see CHEF-5172
+ if Chef::Config[:daemonize] || Chef::Config[:interval]
+ trap("TERM") do
+ Chef::Log.info("SIGTERM received, exiting gracefully")
+ @exit_gracefully = true
+ SELF_PIPE[1].putc('.')
+ end
end
end
diff --git a/chef/spec/unit/application/client_spec.rb b/chef/spec/unit/application/client_spec.rb
index 6f1f1c4b22..479f4bd49e 100644
--- a/chef/spec/unit/application/client_spec.rb
+++ b/chef/spec/unit/application/client_spec.rb
@@ -137,11 +137,12 @@ end
describe Chef::Application::Client, "run_application", :unix_only do
before do
- Chef::Config[:daemonize] = false
+ Chef::Config[:daemonize] = true
Chef::Config[:interval] = 10
@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