7bb09ae83aa4a2a65e93a10390c51c75d69f34d3
[platform/upstream/coreutils.git] / tests / install / trap
1 #!/bin/sh
2 # Ensure that `install -s' doesn't infloop when its parent
3 # process traps CHLD signal.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   ginstall --version
8 fi
9
10 pwd=`pwd`
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
12 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
13 trap '(exit $?); exit $?' 1 2 13 15
14
15 framework_failure=0
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
18
19 if test $framework_failure = 1; then
20   echo "$0: failure in testing framework" 1>&2
21   (exit 1); exit 1
22 fi
23
24 fail=0
25
26 # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
27 (
28   # ash doesn't support "trap '' CHLD"; it knows only signal numbers.
29   sig=`$pwd/../../src/kill -l CHLD 2>/dev/null` && trap '' $sig
30
31   # Before 2004-04-21, install would infloop, in the `while (wait...' loop:
32   exec ginstall -s $pwd/../../src/ginstall$EXEEXT .
33 )
34
35 (exit $fail); exit $fail