#!/bin/sh
# $Id: t-exit-0.sh,v 1.9 2007/09/29 02:10:07 ca Exp $
# Copyright (c) 2004 Sendmail, Inc. and its suppliers.
#	All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
# ----------------------------------------
# test restart: don't restart program because of EX_USAGE exit code
# ----------------------------------------
#
test -s stop && exit 1
#
# set for verbose mode to -V...
V=""
ERRS=0
OUT=mcp.out
PIDS=pids
CONF=exit.conf
CNTF=exit.cnt
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} ${CNTF}
echo 0 > ${CNTF}
#exit	 _ _ _ _ _ wait	_ 1 1 ${USER} _	./t-exit t-exit -f ${CNTF} -s 1
cat > ${CONF} <<EOF
exit {
	start_action = wait;
	min_processes = 1;
	max_processes = 1;
	user = ${USER};
	path = ./t-exit;
	arguments = "t-exit -f ${CNTF} -s 1";
}
EOF
./mcp -D -t -dddd ${CONF} > ${OUT} 2>&1 &
echo $! >> ${PIDS}
sleep 3
CNT=1
if test -s ${CNTF}
then
  C=`cat ${CNTF}`
  if test ${C} -ne ${CNT}
  then
    ${VERBOSE} && echo "counter ${CNTF} wrong: got ${C}, expected ${CNT}"
    ERRS=`expr ${ERRS} + 1 `
  fi
else
  ${VERBOSE} && echo "missing ${CNTF}"
  ERRS=`expr ${ERRS} + 1 `
fi

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

exit ${ERRS}


syntax highlighted by Code2HTML, v. 0.9.1