84f1f2a4afb1df5d1455d32911ec0a13ee806584
[platform/upstream/bash.git] / builtins / psize.sh
1 #! /bin/sh
2 #
3 # psize.sh -- determine this system's pipe size, and write a define to
4 #             pipesize.h so ulimit.c can use it.
5
6 TMPDIR=/tmp
7 TMPNAME=pipsize.$$
8 TMPFILE=$TMPDIR/$TMPNAME
9
10 trap 'rm -f $TMPFILE' 0 1 2 3 6 15
11
12 echo "/*"
13 echo " * pipesize.h"
14 echo " *"
15 echo " * This file is automatically generated by psize.sh"
16 echo " * Do not edit!"
17 echo " */"
18 echo ""
19
20 #
21 # Try to avoid tempfile races.  We can't really check for the file's
22 # existance before we run psize.aux, because `test -e' is not portable,
23 # `test -h' (test for symlinks) is not portable, and `test -f' only
24 # checks for regular files
25 #
26 rm -f $TMPFILE
27
28 ./psize.aux 2>$TMPFILE | sleep 3
29
30 if [ -s $TMPFILE ]; then
31         echo "#define PIPESIZE `cat $TMPFILE`"
32 else
33         echo "#define PIPESIZE 512"
34 fi
35
36 exit 0