#!/bin/sh
#
#   Copyright (c) 1988-1993 Frame Technology Corp. All rights reserved.
#
#   $Id: fm_stop_index,v 1.3 1994/02/03 20:30:49 lss Exp $
#
# interrupt the fa.txtindex API client process

case $# in
0)
    ;;
*)
    echo "Usage: fm_stop_index (no arguments)"
    echo "Interrupts indexing for text retrieval"
    exit 1;
    ;;
esac

file=/tmp/interrupt$$

if [ "`uname -s`" = "SunOS" ]; then
	if [ "`uname -r`" = "5.2" -o "`uname -r`" = "5.3" ]; then
		/bin/ps -c | grep " fa.txtin\$" >$file
	else
		/bin/ps cgx | grep " fa.txtindex\$" >$file
	fi
else
	/bin/ps cgx | grep " fa.txtindex\$" >$file
fi

lines=`wc -l $file | awk '{ print $1 }'`
case $lines in
0)
    echo "No indexing API clients found."
    exitval=1
    ;;
1)
    pid=`awk '{ print $1 }' <$file`
    echo kill -USR1 $pid
    kill -USR1 $pid
    exitval=$?
    ;;
*)
    echo "$lines indexing API clients found:"
    cat $file
    exitval=2
    ;;
esac

rm $file
exit $exitval
