#!/bin/sh
# $Id: t-exit-2.sh,v 1.2 2007/09/29 02:10:07 ca Exp $
#
# ----------------------------------------
# test restart: don't try to restart program, it doesn't exist
# ----------------------------------------
#
test -s stop && exit 1
#
# set for verbose mode to -V...
V=""
ERRS=0
OUT=mcp.out
PIDS=pids
CONF=exit.conf
VERBOSE=false
SD=`dirname $0`
. ${SD}/../check2/user.sh
if test $# -ge 1
then
  if test "X"$1 = "X-v"
  then
    VERBOSE=true;
  fi
fi

rm -f ${PIDS} ${OUT}
cat > ${CONF} <<EOF
exit {
	start_action = wait;
	min_processes = 1;
	max_processes = 1;
	user = ${USER};
	path = ./mIssIng;
	arguments = "mIssIng";
}
EOF
./mcp -D -t -dddd ${CONF} > ${OUT} 2>&1 &
echo $! >> ${PIDS}
sleep 3
CNT=1
if grep 'reaped, status 0x4e00' ${OUT} > /dev/null
then
  C=`grep 'mcp: start=exit' ${OUT} | wc -l`
  if test ${C} -ne ${CNT}
  then
    ${VERBOSE} && echo "wrong number of starts: $C in ${OUT}"
    ERRS=`expr ${ERRS} + 1 `
  fi
else
  ${VERBOSE} && echo "missing 'reaped, status 0x4e00' in ${OUT}"
  ERRS=`expr ${ERRS} + 1 `
fi

for i in `cat ${PIDS}`
do
  kill ${i}
done

exit ${ERRS}


syntax highlighted by Code2HTML, v. 0.9.1