i-bash/builtins/psize.sh

37 lines
770 B
Bash
Raw Normal View History

1996-08-26 18:22:31 +00:00
#! /bin/sh
#
# psize.sh -- determine this system's pipe size, and write a define to
# pipesize.h so ulimit.c can use it.
1998-04-17 19:52:44 +00:00
TMPDIR=/tmp
TMPNAME=pipsize.$$
TMPFILE=$TMPDIR/$TMPNAME
trap 'rm -f $TMPFILE' 0 1 2 3 6 15
1996-08-26 18:22:31 +00:00
echo "/*"
echo " * pipesize.h"
echo " *"
echo " * This file is automatically generated by psize.sh"
echo " * Do not edit!"
echo " */"
echo ""
1998-04-17 19:52:44 +00:00
#
# Try to avoid tempfile races. We can't really check for the file's
# existance before we run psize.aux, because `test -e' is not portable,
# `test -h' (test for symlinks) is not portable, and `test -f' only
# checks for regular files
#
rm -f $TMPFILE
./psize.aux 2>$TMPFILE | sleep 3
1996-08-26 18:22:31 +00:00
1998-04-17 19:52:44 +00:00
if [ -s $TMPFILE ]; then
echo "#define PIPESIZE `cat $TMPFILE`"
1996-08-26 18:22:31 +00:00
else
echo "#define PIPESIZE 512"
fi
exit 0