summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hinderliter <tim@opscode.com>2010-10-25 15:08:31 -0700
committerChris Walters <cw@opscode.com>2010-10-28 10:28:01 -0700
commit505a75b6808ed1bc723a25ba02fe8ef7411d528e (patch)
tree61f472c4ca3faf0adf4abdea2cf4da5c99a90640
parente3299d6f332ccbafcc8da6fe38f1c77d25483394 (diff)
downloadchef-505a75b6808ed1bc723a25ba02fe8ef7411d528e.tar.gz
fix CHEF-1807 by killing child chef-client with SIGKILL after killing it with SIGINT -- works around OHAI-223
-rw-r--r--features/steps/run_client_steps.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/features/steps/run_client_steps.rb b/features/steps/run_client_steps.rb
index f1f517495e..34e6ce2180 100644
--- a/features/steps/run_client_steps.rb
+++ b/features/steps/run_client_steps.rb
@@ -65,13 +65,29 @@ When /^I run the chef\-client with '(.+)' for '(.+)' seconds$/ do |args, run_for
end
When /^I run the chef\-client for '(.+)' seconds$/ do |run_for|
- cid = Process.fork {
+ cid = Process.fork {
sleep run_for.to_i
- Process.kill("INT", /^(.+chef\-client.+\-i.*)$/.match(`ps -ef`).to_s.split[1].to_i)
- exit
- }
+
+ client_pid = `ps ax | grep chef-client | grep -v grep | grep -v rake | grep -v cucumber | awk '{ print $1 }'`.to_i
+
+ # Send a SIGINT to the child process so it has a chance to cleanly exit,
+ # including flushing its stdout.
+ Process.kill("INT", client_pid)
+
+ sleep 1
+
+ # Send KILL to the child chef-client. Due to OHAI-223, where ohai sometimes
+ # ignores/doesn't exit correctly on receipt of SIGINT, brutally kill the
+ # subprocess.
+ begin
+ Process.kill("KILL", client_pid)
+ rescue Errno::ESRCH
+ # SIGINT worked above, so the KILL failed. Ignore it as this means things
+ # are working the way they're supposed to.
+ end
+ }
When 'I run the chef-client'
- Process.wait2(cid)
+ Process.waitpid2(cid)
end
When /^I run the chef\-client at log level '(.+)'$/ do |log_level|