From b811b334aeb57b426a03daa0ef3ccacbe0ff33d0 Mon Sep 17 00:00:00 2001
From: Premysl Hruby <dfenze@gmail.com>
Date: Tue, 3 Apr 2012 14:18:35 +0200
Subject: [PATCH] in kill_server send the signal once, then wait for up to 5sec
 before sending lethal SIGKILL

---
 tests/support/server.tcl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tests/support/server.tcl b/tests/support/server.tcl
index 984270ad..b1ab38fc 100644
--- a/tests/support/server.tcl
+++ b/tests/support/server.tcl
@@ -46,11 +46,16 @@ proc kill_server config {
     }
 
     # kill server and wait for the process to be totally exited
+    catch {exec kill $pid}
     while {[is_alive $config]} {
-        if {[incr wait 10] % 1000 == 0} {
+        incr wait 10
+
+        if {$wait >= 5000} {
+            puts "Forcing process $pid to exit..."
+            catch {exec kill -KILL $pid}
+        } elseif {$wait % 1000 == 0} {
             puts "Waiting for process $pid to exit..."
         }
-        catch {exec kill $pid}
         after 10
     }