+function full_cleanup ()
+{
+ if [ -n "${SESSIOND_PIDS}" ] || [ -n "${RELAYD_PIDS}" ]; then
+ kill -9 ${SESSIOND_PIDS} ${RELAYD_PIDS} > /dev/null 2>&1
+ fi
+
+ # Disable trap for SIGTERM since the following kill to the
+ # pidgroup will be SIGTERM. Otherwise it loops.
+ # The '-' before the pid number ($$) indicates 'kill' to signal the
+ # whole process group.
+ trap - SIGTERM && kill -- -$$
+}
+
+
+trap full_cleanup SIGINT SIGTERM
+