#!/bin/sh # To use this script, rename it to onsessionclose and put it in /etc/security. # Then edit the OFFENDERS line below and insert all processes that just won't # die when their users log out, seperated by a "|". OFFENDERS="kdeinit|artsd" KILL="kill" SIGS="TERM HUP KILL" EGREP=/bin/egrep AWK=/usr/bin/awk XARGS=/usr/bin/xargs LOGGER=/usr/bin/logger if [ "x$1" != "x" ]; then $LOGGER "Killing $OFFENDERS for $1" for sig in $SIGS; do sleep 2 ps --no-headers -u $1 -U $1 -o pid,cmd | $EGREP "$OFFENDERS" | $EGREP -v egrep | $AWK '{print $1}' | $XARGS $KILL -$sig done fi