#!/bin/sh
#
# $Revision: 1.2 $
#
# rwhocache, which is a bash script, seems to trigger a bug in certain
# versions of bash (some kind of memory leak which ultimately causes
# it to crash).
#
# This script periodically checks if rwhocache is still running and
# restarts it if necessary.  You may want to start it from the
# boot-time startup script for rwhod++.

rwhocache=/var/spool/rwho/bin/rwhocache

prog=rwhoca

sleep_time=180   # seconds

PATH=$PATH:/usr/ucb

while true; do

    sleep $sleep_time

    # ps -ae should work on all platforms...

    ps -ae |grep -v grep |grep $prog >/dev/null && continue

    logger -p daemon.crit -t "`basename $0`" restarting rwhocache...

    $rwhocache >/dev/console 2>&1 &
done
