#! /usr/bin/sh
#
# ident	"@(#)preremove	1.1	01/01/22 SMI"
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#

PATH="/usr/bin:/usr/sbin"
export PATH

if [ -z "$PKG_INSTALL_ROOT" ]
then
    PKG_INSTALL_ROOT="/"
fi

kill_all_processes() {
#
#  $1 = unique string used to identify process in ps output
#  $2 = signal to send to the process
#

    pids=`/usr/ucb/ps -ww -a -g -x | /usr/bin/fgrep -v grep | \
        /usr/bin/fgrep "$1" | /usr/bin/awk '{print $1}'`
    for each_pid in $pids
    do
        if [ -z "$2" ] ; then
            /usr/bin/kill "$each_pid" >/dev/null 2>&1
        else
            /usr/bin/kill -s "$2" "$each_pid" >/dev/null 2>&1
        fi
    done

}

#
#Remove the .so file which was copied at the time od setup
#and send HUP signal to related process.
#

if [ -f "$PKG_INSTALL_ROOT/usr/lib/sysevent/modules/em_slm.so" ] ; then
    /usr/bin/rm -f  $PKG_INSTALL_ROOT/usr/lib/sysevent/modules/em_slm.so > /dev/null 2>&1
    kill_all_processes "/usr/lib/sysevent/syseventd" "HUP"
fi

exit 0
