#! /bin/sh
### BEGIN INIT INFO
# Provides:          sendsigs
# Required-Start:    
# Required-Stop: 
# Default-Start:     6
# Default-Stop:       
# Short-Description: Kill all remaining processes.
# Description: 
### END INIT INFO

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

. /lib/lsb/init-functions

do_stop () {
	OMITPIDS=
	if [ -e /var/run/sendsigs.omit ]; then
		for pid in $(cat /var/run/sendsigs.omit); do
			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
		done
	fi

	# Kill all processes.
	log_action_begin_msg "Terminating all remaining processes"
	killall5 -15 $OMITPIDS
	log_action_end_msg 0
	sleep 5
	log_action_begin_msg "Sending all processes the KILL signal"
	killall5 -9 $OMITPIDS
	log_action_end_msg 0
}

case "$1" in
  start)
	# No-op
	;;
  restart|reload|force-reload)
	echo "Error: argument '$1' not supported" >&2
	exit 3
	;;
  stop)
	do_stop
	if which usplash_down >/dev/null; then
		usplash_down
	fi
	;;
  *)
	echo "Usage: $0 start|stop" >&2
	exit 3
	;;
esac

:
