home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # kall - kill all processes belonging to this user that match
- # specified string.
-
- signal=`echo $1 | grep '^\-.*'`
- me=`basename $0`
-
- if [ "$signal" != "" ]; then
- shift
- else
- signal="-TERM"
- fi
-
- if [ "$1" = "" ]; then
- echo "usage: $me [-signal] string [string...]"
- echo " kills all of your processes where command name matches"
- echo " any of the given strings."
- exit
- fi
-
- msg="0"
-
- while [ "$1" != "" ]; do
-
- # NOTE: You may have to modify the next line, since PS is non-portable.
- # The 'awk' command picks out the process IDs to pass them on to kill.
- rprocs=`ps cx | awk '{if(prog == $NF && $1 != mypid) print $1}' prog=$1 mypid=$$ -`
- if [ "$rprocs" != "" ]; then
- msg="1"
- echo -n "${me}: Sending $signal signal to $1 process(es)"
- echo '...'
- kill $signal $rprocs
- fi
- shift
- done
-
- if [ $msg = "1" ]; then
- echo "${me}: Done."
- fi
-