From 9a281b88a714a70f1ca2d9c178e3d38dcecc3340 Mon Sep 17 00:00:00 2001 From: raylu Date: Wed, 13 Jul 2016 12:11:54 -0700 Subject: [PATCH] Don't use Timeout and don't catch ECHILD Timeout is flaky We have a pid - one of the waitpid2s in subprocess must succeed, so we should never get ECHILD --- .../_lib/helpers/einhorn_helpers.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/integration/_lib/helpers/einhorn_helpers.rb b/test/integration/_lib/helpers/einhorn_helpers.rb index 464e2bd..b95d24f 100644 --- a/test/integration/_lib/helpers/einhorn_helpers.rb +++ b/test/integration/_lib/helpers/einhorn_helpers.rb @@ -40,28 +40,28 @@ def with_running_einhorn(cmdline, options = {}) begin stdout, stderr = process.communicate rescue Errno::ECHILD - # It's dead, and we're not getting anything. This is - # peaceful. + # It's dead, and we're not getting anything. This is peaceful. end end yield(process) if block_given? - rescue Exception => e + rescue unless (status = process.poll) && status.exited? process.terminate end raise ensure unless (status = process.poll) && status.exited? - begin - Timeout.timeout(10) do # (Argh, I'm so sorry) - status = process.wait + for i in 1..10 do + status = process.poll + if status && status.exited? + break end - rescue Timeout::Error + sleep(1) + end + unless status && status.exited? $stderr.puts "Could not get Einhorn to quit within 10 seconds, killing it forcefully..." process.send_signal("KILL") status = process.wait - rescue Errno::ECHILD - # Process is dead! end end communicator.join