#! /bin/sh
#
# sendsigs	Kill all remaining processes.
#
# Version:      @(#)sendsigs  2.75  22-Jun-1998  miquels@cistron.nl
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin

OMIT_PIDS=""
OMIT_APPS="novacomd \
           pmklogd \
           pmsyslogd \
"

# Omit any apps explicitly listed above
for APPNAME in novacomd pmklogd pmsyslogd; do
    for PID in $(pidof $APPNAME); do
        OMIT_PIDS="$OMIT_PIDS -o $PID"
    done
done

# Omit any pids listed in the omit directory.  currently only
# watchdog.sh uses this directory.  Beware: killall5 has a hard-coded
# limit to the number of -o options and exits (kills nothing) if that
# number is exceeded.
if [ -d /tmp/sendsigs.omit.d/ ]; then
	for PIDFILE in /tmp/sendsigs.omit.d/*; do
		[ -f "$PIDFILE" ] || continue
		for PID in $(cat $PIDFILE); do
            OMIT_PIDS="$OMIT_PIDS -o $PID"
		done
	done
fi

# Kill all processes.
echo "$0: Sending all processes but $OMIT_PIDS the TERM signal..." | logger -s
killall5 -15 $OMIT_PIDS
sleep 5
echo "$0: Sending all processes but $OMIT_PIDS the KILL signal..." | logger -s
killall5 -9 $OMIT_PIDS

: exit 0
