Fix problems with certain shells (e.g., FreeBSD, Cygwin) clearing the

exit status in multiline traps.
This commit is contained in:
Peter Eisentraut 2004-12-12 15:34:15 +00:00
parent 984791e0e1
commit cf5539112c
1 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.50 2004/11/17 18:06:04 tgl Exp $ # $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.51 2004/12/12 15:34:15 petere Exp $
me=`basename $0` me=`basename $0`
: ${TMPDIR=/tmp} : ${TMPDIR=/tmp}
@ -238,18 +238,20 @@ PGDATESTYLE='ISO, MDY'; export PGDATESTYLE
# with the result of the last shell command before the `exit'. Hence # with the result of the last shell command before the `exit'. Hence
# we have to write `(exit x); exit' below this point. # we have to write `(exit x); exit' below this point.
trap ' exit_trap(){
savestatus=$? savestatus=$1
if [ -n "$postmaster_pid" ]; then if [ -n "$postmaster_pid" ]; then
kill -2 "$postmaster_pid" kill -2 "$postmaster_pid"
wait "$postmaster_pid" wait "$postmaster_pid"
unset postmaster_pid unset postmaster_pid
fi fi
rm -f "$TMPFILE" && exit $savestatus rm -f "$TMPFILE" && exit $savestatus
' 0 }
trap ' trap 'exit_trap $?' 0
savestatus=$?
sig_trap() {
savestatus=$1
echo; echo "caught signal" echo; echo "caught signal"
if [ -n "$postmaster_pid" ]; then if [ -n "$postmaster_pid" ]; then
echo "signalling fast shutdown to postmaster with pid $postmaster_pid" echo "signalling fast shutdown to postmaster with pid $postmaster_pid"
@ -258,7 +260,9 @@ trap '
unset postmaster_pid unset postmaster_pid
fi fi
(exit $savestatus); exit (exit $savestatus); exit
' 1 2 13 15 }
trap 'sig_trap $?' 1 2 13 15