Catch SERVERQUIT timeout in ssl test scripts
diff --git a/tests/compat.sh b/tests/compat.sh
index 0146e15..06243bd 100755
--- a/tests/compat.sh
+++ b/tests/compat.sh
@@ -768,6 +768,10 @@
 stop_server() {
     case $SERVER_NAME in
         [Pp]olar*)
+            # start watchdog in case SERVERQUIT fails
+            ( sleep 20; echo "SERVERQUIT TIMEOUT"; kill $MAIN_PID ) &
+            WATCHDOG_PID=$!
+
             # we must force a PSK suite when in PSK mode (otherwise client
             # auth will fail), so try every entry in $P_CIPHERS in turn (in
             # case the first one is not implemented in this configuration)
@@ -779,12 +783,16 @@
                     break
                 fi
             done
+
+            wait $PROCESS_ID 2>/dev/null
+            kill $WATCHDOG_PID 2>/dev/null
+            wait $WATCHDOG_PID 2>/dev/null
             ;;
         *)
             kill $PROCESS_ID 2>/dev/null
+            wait $PROCESS_ID 2>/dev/null
     esac
 
-    wait $PROCESS_ID 2>/dev/null
 
     if [ "$MEMCHECK" -gt 0 ]; then
         if is_polar "$SERVER_CMD" && has_mem_err $SRV_OUT; then
@@ -952,6 +960,9 @@
     esac
 done
 
+# used by watchdog
+MAIN_PID="$$"
+
 # Pick a "unique" port in the range 10000-19999.
 PORT="0000$$"
 PORT="1$(echo $PORT | tail -c 4)"