#!/bin/sh
# $Id: t-rdwr-fd.sh,v 1.8 2005/01/11 23:53:41 ca Exp $
# Copyright (c) 2003-2005 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 passing filedescriptor between two programs
#
test -s stop && exit 1
#
SRV="error.srv"
CLT="error.clt"
FILE="rdwrfd.txt"
SOCK="rdwrfd"
date > ${FILE}
P1="./t-rdwr-fd"
P2="./t-rdwr-st"

test -x ${P1} || exit 1
test -x ${P2} || exit 1

# programs to test
PRGS="${P1}"
# doesn't work (yet?)
PRGS="${P1} ${P2}"
#

for S in ${PRGS}
do

for C in ${PRGS}
do

rm -f ${SRV} ${CLT} ${SOCK}
${S} -s > ${SRV} &
sleep 1
${C} -c 2> ${CLT}
wait
sleep 1

if diff ${FILE} ${SRV} >/dev/null
then
	:
else
	echo ERROR: expected
	cat ${FILE}
	echo got
	cat ${SRV}
	exit 1
fi
rm -f ${SRV} ${CLT}
sleep 3

done
done

exit 0


syntax highlighted by Code2HTML, v. 0.9.1