source: vendor/bash/3.1/builtins/psize.sh@ 3228

Last change on this file since 3228 was 3228, checked in by bird, 19 years ago

bash 3.1

File size: 1.0 KB
Line 
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# try to use mktemp(1) if the system supports it
8{ TMPFILE="`mktemp $TMPDIR/pipsize.XXXXXX 2>/dev/null`"; } 2>/dev/null
9used_mktemp=true
10
11if [ -z "$TMPFILE" ]; then
12 TMPNAME=pipsize.$$
13 TMPFILE=$TMPDIR/$TMPNAME
14 used_mktemp=false
15fi
16
17trap 'rm -f "$TMPFILE" ; exit 1' 1 2 3 6 15
18trap 'rm -f "$TMPFILE"' 0
19
20echo "/*"
21echo " * pipesize.h"
22echo " *"
23echo " * This file is automatically generated by psize.sh"
24echo " * Do not edit!"
25echo " */"
26echo ""
27
28#
29# Try to avoid tempfile races. We can't really check for the file's
30# existance before we run psize.aux, because `test -e' is not portable,
31# `test -h' (test for symlinks) is not portable, and `test -f' only
32# checks for regular files. If we used mktemp(1), we're ahead of the
33# game.
34#
35$used_mktemp || rm -f "$TMPFILE"
36
37./psize.aux 2>"$TMPFILE" | sleep 3
38
39if [ -s "$TMPFILE" ]; then
40 echo "#define PIPESIZE `cat "$TMPFILE"`"
41else
42 echo "#define PIPESIZE 512"
43fi
44
45exit 0
Note: See TracBrowser for help on using the repository browser.