X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fpsize.sh;h=84f1f2a4afb1df5d1455d32911ec0a13ee806584;hb=cce855bc5b117cb7ae70064131120687bc69fac0;hp=961becd348dd6001b2452b8900feec491b214105;hpb=e8ce775db824de329b81293b4e5d8fbd65624528;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/psize.sh b/builtins/psize.sh index 961becd..84f1f2a 100755 --- a/builtins/psize.sh +++ b/builtins/psize.sh @@ -3,6 +3,12 @@ # 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 " *" @@ -11,14 +17,20 @@ echo " * Do not edit!" echo " */" echo "" -./psize.aux 2>/tmp/pipesize | sleep 3 +# +# 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 /tmp/pipesize ]; then - echo "#define PIPESIZE `cat /tmp/pipesize`" +if [ -s $TMPFILE ]; then + echo "#define PIPESIZE `cat $TMPFILE`" else echo "#define PIPESIZE 512" fi -rm -f /tmp/pipesize - exit 0