#
# PROPRIETARY/CONFIDENTIAL. Use of this product is subject to
# license terms. Copyright C 2001-2003 Sun Microsystems, Inc.
# All rights reserved.
#

if "${ROOT_INSTANCE}/status-dps" > /dev/null 2>&1 ; then
   pid=`${DPS_CAT} "${PID_FILE}"`

   ${DPS_KILL} -2 $pid
   ${DPS_SLEEP} 2
   if "${ROOT_INSTANCE}/status-dps" > /dev/null 2>&1 ; then
      ${DPS_KILL} -9 $pid
      ${DPS_SLEEP} 2
   else
     # workaround for bugid 5078970
	testpid=`${DPS_PS} -p $pid | ${DPS_GREP} ldapfwd | ${DPS_SED} -e 's/^  *//' -e 's/ .*//'`
	if ${DPS_TEST} "$testpid" = "$pid" ; then
	  ${DPS_KILL} -2 $pid
	  ${DPS_SLEEP} 2
	fi
   fi
   if "${ROOT_INSTANCE}/status-dps" > /dev/null 2>&1 ; then
      ${DPS_ECHO} "DPS for ${INSTANCE} will not stop despite being killed."
      exit 1
   fi
   ${DPS_ECHO} "DPS for ${INSTANCE} has been stopped."
else
   ${DPS_ECHO} "DPS for ${INSTANCE} is not running."
fi

if ${DPS_TEST} -f "${PORT_FILE}" ; then
   ${DPS_RM} ${PORT_FILE}
fi

exit 0
