From: Peter Eisentraut Date: Sun, 12 Dec 2004 15:34:15 +0000 (+0000) Subject: Fix problems with certain shells (e.g., FreeBSD, Cygwin) clearing the X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=d7ad9d3e03497aff27b20ea948c767bcccd835e9;p=users%2Fbernd%2Fpostgres.git Fix problems with certain shells (e.g., FreeBSD, Cygwin) clearing the exit status in multiline traps. --- diff --git a/src/test/regress/pg_regress.sh b/src/test/regress/pg_regress.sh index 08b4022778..861609dcc1 100644 --- a/src/test/regress/pg_regress.sh +++ b/src/test/regress/pg_regress.sh @@ -238,18 +238,20 @@ PGDATESTYLE='ISO, MDY'; export PGDATESTYLE # with the result of the last shell command before the `exit'. Hence # we have to write `(exit x); exit' below this point. -trap ' - savestatus=$? +exit_trap(){ + savestatus=$1 if [ -n "$postmaster_pid" ]; then kill -2 "$postmaster_pid" wait "$postmaster_pid" unset postmaster_pid fi rm -f "$TMPFILE" && exit $savestatus -' 0 +} + +trap 'exit_trap $?' 0 -trap ' - savestatus=$? +sig_trap() { + savestatus=$1 echo; echo "caught signal" if [ -n "$postmaster_pid" ]; then echo "signalling fast shutdown to postmaster with pid $postmaster_pid" @@ -258,7 +260,9 @@ trap ' unset postmaster_pid fi (exit $savestatus); exit -' 1 2 13 15 +} + +trap 'sig_trap $?' 1 2 13 15