#!/bin/sh

# To use this script, rename it to pam_script 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 in there, seperated by a "|".

OFFENDERS="kdeinit|artsd"
KILL="kill"
SIGS="TERM HUP KILL"
if [ "x$1" != "x" ]; then
	/usr/bin/logger "Killing $OFFENDERS for $1"
	for sig in $SIGS; do
		sleep 2
		ps --no-headers -u $1 -U $1 -o pid,cmd | egrep "$OFFENDERS" | grep -v grep | awk '{print $1}' | xargs -i{} $KILL -$sig {}
	done
fi
