diff options
author | John Keiser <john@johnkeiser.com> | 2015-09-29 13:54:10 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-09-29 16:02:09 -0700 |
commit | 9d4d0475bc82a35671e4f6f720d9b7ff3ae0be81 (patch) | |
tree | 73a94af62d9a8aae0743d502b2f84738ca3338fd /spec | |
parent | 293435a5f71662c5ff8da84dd56ac897fcb6c89b (diff) | |
download | chef-9d4d0475bc82a35671e4f6f720d9b7ff3ae0be81.tar.gz |
Simplify kill loop with WNOHANGjk/print-race
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/run_lock_spec.rb | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index c559ee3421..78b3847d19 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -383,19 +383,12 @@ describe Chef::RunLock do example.log_event("#{name}.stop (pid #{pid})") begin # Send it the kill signal over and over until it dies - start_time = Time.now - dead = false - while Time.now - start_time < CLIENT_PROCESS_TIMEOUT + Timeout::timeout(CLIENT_PROCESS_TIMEOUT) do Process.kill(:KILL, pid) - Timeout::timeout(0.2) do - begin - Process.waitpid2(pid) - dead = true - rescue Timeout::Error - end + while !Process.waitpid2(pid, Process::WNOHANG) + sleep(0.05) end end - raise Timeout::Error, "took more than 10s to kill process #{pid}" if !dead example.log_event("#{name}.stop finished (stopped pid #{pid})") # Process not found is perfectly fine when we're trying to kill a process :) rescue Errno::ESRCH |