Skip to content

Commit cf55391

Browse files
committed
Fix problems with certain shells (e.g., FreeBSD, Cygwin) clearing the
exit status in multiline traps.
1 parent 984791e commit cf55391

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/test/regress/pg_regress.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.50 2004/11/17 18:06:04 tgl Exp $
2+
# $PostgreSQL: pgsql/src/test/regress/pg_regress.sh,v 1.51 2004/12/12 15:34:15 petere Exp $
33

44
me=`basename $0`
55
: ${TMPDIR=/tmp}
@@ -238,18 +238,20 @@ PGDATESTYLE='ISO, MDY'; export PGDATESTYLE
238238
# with the result of the last shell command before the `exit'. Hence
239239
# we have to write `(exit x); exit' below this point.
240240

241-
trap '
242-
savestatus=$?
241+
exit_trap(){
242+
savestatus=$1
243243
if [ -n "$postmaster_pid" ]; then
244244
kill -2 "$postmaster_pid"
245245
wait "$postmaster_pid"
246246
unset postmaster_pid
247247
fi
248248
rm -f "$TMPFILE" && exit $savestatus
249-
' 0
249+
}
250+
251+
trap 'exit_trap $?' 0
250252

251-
trap '
252-
savestatus=$?
253+
sig_trap() {
254+
savestatus=$1
253255
echo; echo "caught signal"
254256
if [ -n "$postmaster_pid" ]; then
255257
echo "signalling fast shutdown to postmaster with pid $postmaster_pid"
@@ -258,7 +260,9 @@ trap '
258260
unset postmaster_pid
259261
fi
260262
(exit $savestatus); exit
261-
' 1 2 13 15
263+
}
264+
265+
trap 'sig_trap $?' 1 2 13 15
262266

263267

264268

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy