aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/psize.sh
blob: 84f1f2a4afb1df5d1455d32911ec0a13ee806584 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/sh
#
# psize.sh -- determine this system's pipe size, and write a define to
#             pipesize.h so ulimit.c can use it.

TMPDIR=/tmp
TMPNAME=pipsize.$$
TMPFILE=$TMPDIR/$TMPNAME

trap 'rm -f $TMPFILE' 0 1 2 3 6 15

echo "/*"
echo " * pipesize.h"
echo " *"
echo " * This file is automatically generated by psize.sh"
echo " * Do not edit!"
echo " */"
echo ""

#
# 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

if [ -s $TMPFILE ]; then
	echo "#define PIPESIZE `cat $TMPFILE`"
else
	echo "#define PIPESIZE 512"
fi

exit 0