bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Numbered signals for shell trap cause z/OS grief


From: Mike Fulton
Subject: RE: Numbered signals for shell trap cause z/OS grief
Date: Sat, 26 Nov 2022 18:23:54 +0000

Hello

Thank you for the detailed analysis and the fixes. Perhaps the most important part of this was uncovering that difference in signal number to name — a very subtle potential problem for z/OS. 

Thanks, Mike

From: Bruno Haible <bruno@clisp.org>
Sent: Saturday, November 26, 2022 6:27:12 AM
To: bug-gnulib@gnu.org <bug-gnulib@gnu.org>
Cc: Mike Fulton <fultonm@ca.ibm.com>
Subject: [EXTERNAL] Re: Numbered signals for shell trap cause z/OS grief
 
Hello Mike,

Mike Fulton wrote:
> I am working on enabling the gnulib tools to work on z/OS. I would like to request a patch to avoid warnings when setting traps in the shell. In particular, z/OS issues a warning when a trap is set for signal 13 instead of SIGPIPE. My proposed patch is as follows, changing numbered signals to named signals. This may also be easier for developers to read that aren't 'signal experts'.
>
> diff --git a/gnulib-tool b/gnulib-tool
> index 028bcf36a..01b2211be 100755
> --- a/gnulib-tool
> +++ b/gnulib-tool
> @@ -1698,7 +1698,7 @@ trap 'exit_status=$?
>        fi
>        rm -rf "$tmp"
>        exit $exit_status' 0
> -for signal in 1 2 3 13 15; do
> +for signal in SIGHUP SIGINT SIGABRT SIGPIPE SIGTERM; do
>    trap '{ signal='$signal'; func_exit 1; }' $signal
>  done
>  signal=0
> @@ -7676,12 +7676,12 @@ fi
>
>  rm -rf "$tmp"
>  # Undo the effect of the previous 'trap' command. Some shellology:
> -# We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
> +# We cannot use "trap - 0 SIGHUP SIGINT SIGABRT SIGPIPE SIGTERM", because Solaris sh would attempt to
>  # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
>  # exit); for the others we need to call 'exit' explicitly. The value of $? is
>  # 128 + signal number and is set before the trap-registered command is run.
>  trap '' 0
> -trap 'func_exit $?' 1 2 3 13 15
> +trap 'func_exit $?' SIGHUP SIGINT SIGABRT SIGPIPE SIGTERM
>
>  exit 0

There are three topics here:
1) The syntax for 'trap'.
2) Signal numbers.
3) Warning on z/OS.


1) === The syntax for 'trap'. ===

trap $action SIGINT
is *not* guaranteed-valid syntax according to POSIX, nor is is portable.

POSIX:2018 <https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#trap >
says
   "The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified
    using a symbolic name, without the SIG prefix, as listed in the tables of
    signal names in the <signal.h> header defined in XBD Headers; for example,
    HUP, INT, QUIT, TERM. Implementations may permit names with the SIG prefix
    or ignore case in signal names as an extension."

An experiment with various shells confirms this: I did

trap 'echo foo' 2
Ctrl-C
trap 'echo bar' INT
Ctrl-C
trap 'echo gik' SIGINT
Ctrl-C

and got these results:

bash                  OK/OK/OK
dash                  OK/OK/"trap: SIGINT: bad trap"
ash                   OK/OK/"trap: SIGINT: bad trap"
zsh                   OK/OK/OK
ksh (NetBSD 5)        OK/OK/"bad signal SIGINT"
busybox (Alpine 3.7)  OK/OK/OK
FreeBSD 11 /bin/sh    OK/OK/OK
NetBSD 5 /bin/sh      OK/OK/OK
OpenBSD 3.8 /bin/sh   OK/OK/"trap: bad signal SIGINT"
macOS /bin/sh         OK/OK/OK
AIX 7 /bin/sh         OK/OK/no effect
Solaris 10 /bin/sh    OK/OK/"trap: bad trap"
Solaris 11 /bin/sh    OK/OK/OK
IRIX 6.5 /bin/sh      OK/OK/"SIGINT: trap --"

So:
  - Using the signal's name without SIG prefix is portable, as demanded by
    POSIX.
  - Using the signal's name with SIG prefix is unportable.


2) === Signal numbers. ===

> This may also be easier for developers to read that aren't 'signal experts'.

I agree with that.

Additionally, by comparing the signal numbers on Linux
  <https://man7.org/linux/man-pages/man7/signal.7.html >
with those on z/OS
  <https://www.ibm.com/docs/en/zos/2.2.0?topic=SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/signals.html>
we see that signal number 3 means something different: SIGQUIT vs. SIGABRT.
SIGQUIT is 3 on Linux but 24 on z/OS.

So, we have two arguments for preferring the symbolic signal names.


3) === Warning on z/OS. ===

> z/OS issues a warning when a trap is set for signal 13 instead of SIGPIPE.

For signal 13, this warning is nonsense, since SIGPIPE == 13 everywhere.
But for signal number 3, or other signals which have different meanings
across platforms, it makes sense.

In fact, such a warning would make sense also in bash on Linux, for signals
7, 10, 12, and ≥ 16.


2022-11-25  Bruno Haible  <bruno@clisp.org>

        In 'trap' commands, prefer symbolic to numeric signal names.
        Reported by Mike Fulton <fultonm@ca.ibm.com> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2022-11/msg00130.html >.
        * gnulib-tool: Use symbolic signal names.
        * posix-modules: Likewise.
        * MODULES.html.sh: Likewise.
        * build-aux/bootstrap (prepare_GNULIB_SRCDIR): Likewise.
        * build-aux/csharpcomp.sh.in: Likewise.
        * build-aux/gnu-web-doc-update: Likewise.
        * top/autogen.sh: Likewise.
        * top/bootstrap-funclib.sh: Likewise.
        * top/gitsub.sh: Likewise.
        * lib/t-idcache: Likewise.
        * tests/havelib/rpath-1: Likewise.
        * tests/havelib/rpath-2_a: Likewise.
        * tests/havelib/rpath-2_b: Likewise.
        * tests/havelib/rpath-3_a: Likewise.
        * tests/havelib/rpath-3_b: Likewise.
        * tests/init.sh: Likewise.
        * tests/test-binary-io.sh: Likewise.
        * tests/test-c-stack.sh: Likewise.
        * tests/test-c-stack2.sh: Likewise.
        * tests/test-dprintf-posix.sh: Likewise.
        * tests/test-fpending.sh: Likewise.
        * tests/test-fprintf-posix.sh: Likewise.
        * tests/test-lseek.sh: Likewise.
        * tests/test-printf-posix.sh: Likewise.
        * tests/test-select-in.sh: Likewise.
        * tests/test-select-out.sh: Likewise.
        * tests/test-sigpipe.sh: Likewise.
        * tests/test-tsearch.sh: Likewise.
        * tests/test-update-copyright.sh: Likewise.
        * tests/test-vdprintf-posix.sh: Likewise.
        * tests/test-vfprintf-posix.sh: Likewise.
        * tests/test-vprintf-posix.sh: Likewise.
        * tests/test-xprintf-posix.sh: Likewise.
        * tests/uniwidth/test-uc_width2.sh: Likewise.

diff --git a/MODULES.html.sh b/MODULES.html.sh
index d48912b13e..02cfe32f06 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3627,15 +3627,15 @@ func_all_modules ()
 
 func_tmpdir
 trap 'exit_status=$?
-      if test "$signal" != 0; then
-        echo "caught signal $signal" >&2
+      if test "$signal" != EXIT; then
+        echo "caught signal SIG$signal" >&2
       fi
       rm -rf "$tmp"
-      exit $exit_status' 0
-for signal in 1 2 3 13 15; do
+      exit $exit_status' EXIT
+for signal in HUP INT QUIT PIPE TERM; do
   trap '{ signal='$signal'; func_exit 1; }' $signal
 done
-signal=0
+signal=EXIT
 
 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">'
 func_begin HTML
@@ -3736,8 +3736,8 @@ func_end HTML
 
 rm -rf "$tmp"
 # Undo the effect of the previous 'trap' command.
-trap '' 0
-trap 'func_exit $?' 1 2 3 13 15
+trap '' EXIT
+trap 'func_exit $?' HUP INT QUIT PIPE TERM
 
 exit 0
 
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index a54c995798..341d05d57e 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -540,7 +540,7 @@ prepare_GNULIB_SRCDIR ()
       elif [ ! -d "$gnulib_path" ]; then
         echo "$0: getting gnulib files..."
 
-        trap cleanup_gnulib 1 2 13 15
+        trap cleanup_gnulib HUP INT PIPE TERM
 
         shallow=
         if test -z "$GNULIB_REVISION"; then
@@ -570,7 +570,7 @@ prepare_GNULIB_SRCDIR ()
           git -C "$gnulib_path" reset --hard FETCH_HEAD
         fi
 
-        trap - 1 2 13 15
+        trap - HUP INT PIPE TERM
       fi
     fi
     GNULIB_SRCDIR=$gnulib_path
diff --git a/build-aux/csharpcomp.sh.in b/build-aux/csharpcomp.sh.in
index 1a690e0a7a..63b5a7013c 100644
--- a/build-aux/csharpcomp.sh.in
+++ b/build-aux/csharpcomp.sh.in
@@ -127,7 +127,7 @@ if test -n "@HAVE_MCS@"; then
 /^Compilation succeeded/d
 }'
   func_tmpdir
-  trap 'rm -rf "$tmp"' 1 2 3 15
+  trap 'rm -rf "$tmp"' HUP INT QUIT TERM
   test -z "$CSHARP_VERBOSE" || echo mcs $options_mcs $sources
   mcs $options_mcs $sources > "$tmp"/mcs.err
   result=$?
diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update
index c041364fbe..28a0e97ef4 100755
--- a/build-aux/gnu-web-doc-update
+++ b/build-aux/gnu-web-doc-update
@@ -153,8 +153,8 @@ cleanup()
   $GIT branch -d $tmp_branch
   exit $__st
 }
-trap cleanup 0
-trap 'exit $?' 1 2 13 15
+trap cleanup EXIT
+trap 'exit $?' HUP INT PIPE TERM
 
 # We must build using sources for which --version reports the
 # just-released version number, not some string like 7.6.18-20761.
diff --git a/gnulib-tool b/gnulib-tool
index 028bcf36ad..b0126e711a 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -1693,15 +1693,15 @@ func_determine_path_separator
 func_gnulib_dir
 func_tmpdir
 trap 'exit_status=$?
-      if test "$signal" != 0; then
-        echo "caught signal $signal" >&2
+      if test "$signal" != EXIT; then
+        echo "caught signal SIG$signal" >&2
       fi
       rm -rf "$tmp"
-      exit $exit_status' 0
-for signal in 1 2 3 13 15; do
+      exit $exit_status' EXIT
+for signal in HUP INT QUIT PIPE TERM; do
   trap '{ signal='$signal'; func_exit 1; }' $signal
 done
-signal=0
+signal=EXIT
 
 # Note: The 'eval' silences stderr output in dash.
 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
@@ -7676,12 +7676,13 @@ fi
 
 rm -rf "$tmp"
 # Undo the effect of the previous 'trap' command. Some shellology:
-# We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
-# execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
-# exit); for the others we need to call 'exit' explicitly. The value of $? is
-# 128 + signal number and is set before the trap-registered command is run.
-trap '' 0
-trap 'func_exit $?' 1 2 3 13 15
+# We cannot use "trap - EXIT HUP INT QUIT PIPE TERM", because Solaris sh would
+# attempt to execute the command "-". "trap '' ..." is fine only for signal EXIT
+# (= normal exit); for the others we need to call 'exit' explicitly. The value
+# of $? is 128 + signal number and is set before the trap-registered command is
+# run.
+trap '' EXIT
+trap 'func_exit $?' HUP INT QUIT PIPE TERM
 
 exit 0
 
diff --git a/lib/t-idcache b/lib/t-idcache
index e4d71af0a2..0a08d49b42 100755
--- a/lib/t-idcache
+++ b/lib/t-idcache
@@ -4,8 +4,8 @@
 
 pwd=`pwd`
 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' EXIT
+trap '(exit $?); exit $?' HUP INT PIPE TERM
 
 srcdir=../..
 framework_failure=0
diff --git a/posix-modules b/posix-modules
index 4629161571..1851538513 100755
--- a/posix-modules
+++ b/posix-modules
@@ -263,15 +263,15 @@ done
 func_gnulib_dir
 func_tmpdir
 trap 'exit_status=$?
-      if test "$signal" != 0; then
-        echo "caught signal $signal" >&2
+      if test "$signal" != EXIT; then
+        echo "caught signal SIG$signal" >&2
       fi
       rm -rf "$tmp"
-      exit $exit_status' 0
-for signal in 1 2 3 13 15; do
+      exit $exit_status' EXIT
+for signal in HUP INT QUIT PIPE TERM; do
   trap '{ signal='$signal'; func_exit 1; }' $signal
 done
-signal=0
+signal=EXIT
 
 (
   # Get the header modules.
diff --git a/tests/havelib/rpath-1 b/tests/havelib/rpath-1
index 2d14f04546..821c304296 100644
--- a/tests/havelib/rpath-1
+++ b/tests/havelib/rpath-1
@@ -1,7 +1,7 @@
 # Common portion of all rpath-1* tests.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 builddir=`pwd`
 global_top_auxdir=`cd "$top_srcdir"/build-aux && pwd`
diff --git a/tests/havelib/rpath-2_a b/tests/havelib/rpath-2_a
index 3570e44441..25fcb9e95f 100644
--- a/tests/havelib/rpath-2_a
+++ b/tests/havelib/rpath-2_a
@@ -1,7 +1,7 @@
 # Common portion of all rpath-2?a? tests.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 builddir=`pwd`
 global_top_auxdir=`cd "$top_srcdir"/build-aux && pwd`
diff --git a/tests/havelib/rpath-2_b b/tests/havelib/rpath-2_b
index e851d0190d..827e611b75 100644
--- a/tests/havelib/rpath-2_b
+++ b/tests/havelib/rpath-2_b
@@ -1,7 +1,7 @@
 # Common portion of all rpath-2?b? tests.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 builddir=`pwd`
 global_top_auxdir=`cd "$top_srcdir"/build-aux && pwd`
diff --git a/tests/havelib/rpath-3_a b/tests/havelib/rpath-3_a
index 6ccc3f8683..d760243204 100644
--- a/tests/havelib/rpath-3_a
+++ b/tests/havelib/rpath-3_a
@@ -1,7 +1,7 @@
 # Common portion of all rpath-3?a? tests.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 builddir=`pwd`
 global_top_auxdir=`cd "$top_srcdir"/build-aux && pwd`
diff --git a/tests/havelib/rpath-3_b b/tests/havelib/rpath-3_b
index 71b4212881..fcdfbe63b0 100644
--- a/tests/havelib/rpath-3_b
+++ b/tests/havelib/rpath-3_b
@@ -1,7 +1,7 @@
 # Common portion of all rpath-3?b? tests.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 builddir=`pwd`
 global_top_auxdir=`cd "$top_srcdir"/build-aux && pwd`
diff --git a/tests/init.sh b/tests/init.sh
index d5d37c98f8..7d6afd16e2 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -702,4 +702,4 @@ test -f "$srcdir/init.cfg" \
 setup_ "$@"
 # This trap is here, rather than in the setup_ function, because some
 # shells run the exit trap at shell function exit, rather than script exit.
-trap remove_tmp_ 0
+trap remove_tmp_ EXIT
diff --git a/tests/test-binary-io.sh b/tests/test-binary-io.sh
index a177d9473f..7bc5aa07f4 100755
--- a/tests/test-binary-io.sh
+++ b/tests/test-binary-io.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp"
 ${CHECKER} ./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
diff --git a/tests/test-c-stack.sh b/tests/test-c-stack.sh
index 54009d3c01..f0bec55e32 100755
--- a/tests/test-c-stack.sh
+++ b/tests/test-c-stack.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="t-c-stack.tmp"
 ${CHECKER} ./test-c-stack${EXEEXT} 2> t-c-stack.tmp
diff --git a/tests/test-c-stack2.sh b/tests/test-c-stack2.sh
index 7f035933f8..b7f8b26bd9 100755
--- a/tests/test-c-stack2.sh
+++ b/tests/test-c-stack2.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="t-c-stack2.tmp"
 
diff --git a/tests/test-dprintf-posix.sh b/tests/test-dprintf-posix.sh
index 188ebe5592..cee608ddbc 100755
--- a/tests/test-dprintf-posix.sh
+++ b/tests/test-dprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-dprintf-posix.tmp t-dprintf-posix.out"
 ${CHECKER} ./test-dprintf-posix${EXEEXT} > t-dprintf-posix.tmp || exit 1
diff --git a/tests/test-fpending.sh b/tests/test-fpending.sh
index abe7d83b99..4acd60a9f5 100755
--- a/tests/test-fpending.sh
+++ b/tests/test-fpending.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfile=
-trap 'rm -fr $tmpfile' 1 2 3 15
+trap 'rm -fr $tmpfile' HUP INT QUIT TERM
 
 tmpfile=test-fpending.t
 
diff --git a/tests/test-fprintf-posix.sh b/tests/test-fprintf-posix.sh
index 5391ee0b7b..b4948b72ef 100755
--- a/tests/test-fprintf-posix.sh
+++ b/tests/test-fprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-fprintf-posix.tmp t-fprintf-posix.out"
 ${CHECKER} ./test-fprintf-posix${EXEEXT} > t-fprintf-posix.tmp || exit 1
diff --git a/tests/test-lseek.sh b/tests/test-lseek.sh
index ff206c66c7..ff553c93b2 100755
--- a/tests/test-lseek.sh
+++ b/tests/test-lseek.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles=t-lseek.tmp
 # seekable files
diff --git a/tests/test-printf-posix.sh b/tests/test-printf-posix.sh
index 3ac993a2e9..480bfdb430 100755
--- a/tests/test-printf-posix.sh
+++ b/tests/test-printf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-printf-posix.tmp t-printf-posix.out"
 ${CHECKER} ./test-printf-posix${EXEEXT} > t-printf-posix.tmp || exit 1
diff --git a/tests/test-select-in.sh b/tests/test-select-in.sh
index 68176d3059..ad86ea2526 100755
--- a/tests/test-select-in.sh
+++ b/tests/test-select-in.sh
@@ -5,7 +5,7 @@
 # of /dev/null.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-select-in.tmp"
 
diff --git a/tests/test-select-out.sh b/tests/test-select-out.sh
index dbeace505e..cfa5e17957 100755
--- a/tests/test-select-out.sh
+++ b/tests/test-select-out.sh
@@ -2,7 +2,7 @@
 # Test select() on file descriptors opened for writing.
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-select-out.out t-select-out.tmp"
 
diff --git a/tests/test-sigpipe.sh b/tests/test-sigpipe.sh
index 58a19acf7c..5c87f6ed50 100755
--- a/tests/test-sigpipe.sh
+++ b/tests/test-sigpipe.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 # Test signal's default behaviour.
 tmpfiles="$tmpfiles t-sigpipeA.tmp"
diff --git a/tests/test-tsearch.sh b/tests/test-tsearch.sh
index dfc80eed5f..28539bd80f 100755
--- a/tests/test-tsearch.sh
+++ b/tests/test-tsearch.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-tsearch.out"
 ${CHECKER} ./test-tsearch${EXEEXT} > t-tsearch.out 2>&1
diff --git a/tests/test-update-copyright.sh b/tests/test-update-copyright.sh
index 29cf6e99a0..5fc9492117 100755
--- a/tests/test-update-copyright.sh
+++ b/tests/test-update-copyright.sh
@@ -28,7 +28,7 @@ PATH=$abs_aux_dir:$PATH
 export PATH
 
 TMP_BASE=update-copyright.test
-trap 'rm -f $TMP_BASE*' 0 1 2 3 15
+trap 'rm -f $TMP_BASE*' EXIT HUP INT QUIT TERM
 
 ## --------------------------------- ##
 ## Skip if user does not have perl.  ##
diff --git a/tests/test-vdprintf-posix.sh b/tests/test-vdprintf-posix.sh
index a2616b3793..7fcfd50fac 100755
--- a/tests/test-vdprintf-posix.sh
+++ b/tests/test-vdprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-vdprintf-posix.tmp t-vdprintf-posix.out"
 ${CHECKER} ./test-vdprintf-posix${EXEEXT} > t-vdprintf-posix.tmp || exit 1
diff --git a/tests/test-vfprintf-posix.sh b/tests/test-vfprintf-posix.sh
index d5453e3f9c..0d0945e411 100755
--- a/tests/test-vfprintf-posix.sh
+++ b/tests/test-vfprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-vfprintf-posix.tmp t-vfprintf-posix.out"
 ${CHECKER} ./test-vfprintf-posix${EXEEXT} > t-vfprintf-posix.tmp || exit 1
diff --git a/tests/test-vprintf-posix.sh b/tests/test-vprintf-posix.sh
index 7e85eb2948..c2625c44c4 100755
--- a/tests/test-vprintf-posix.sh
+++ b/tests/test-vprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-vprintf-posix.tmp t-vprintf-posix.out"
 ${CHECKER} ./test-vprintf-posix${EXEEXT} > t-vprintf-posix.tmp || exit 1
diff --git a/tests/test-xprintf-posix.sh b/tests/test-xprintf-posix.sh
index f46059fa11..35da74256a 100755
--- a/tests/test-xprintf-posix.sh
+++ b/tests/test-xprintf-posix.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles t-xprintf-posix.tmp t-xprintf-posix.out"
 ${CHECKER} ./test-xprintf-posix${EXEEXT} > t-xprintf-posix.tmp || exit 1
diff --git a/tests/uniwidth/test-uc_width2.sh b/tests/uniwidth/test-uc_width2.sh
index 2833aef189..ae6f8f4594 100755
--- a/tests/uniwidth/test-uc_width2.sh
+++ b/tests/uniwidth/test-uc_width2.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 tmpfiles=""
-trap 'rm -fr $tmpfiles' 1 2 3 15
+trap 'rm -fr $tmpfiles' HUP INT QUIT TERM
 
 tmpfiles="$tmpfiles uc_width.out"
 ${CHECKER} ./test-uc_width2${EXEEXT} | LC_ALL=C tr -d '\r' > uc_width.out
diff --git a/top/autogen.sh b/top/autogen.sh
index 02028f272b..81db3fe035 100755
--- a/top/autogen.sh
+++ b/top/autogen.sh
@@ -305,7 +305,7 @@ grep '^[     ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
 if test $with_gettext = yes || test $use_libtool = 1; then
 
   tempbase=.bootstrap$$
-  trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
+  trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM
 
   > $tempbase.0 > $tempbase.1 &&
   find . ! -type d -print | sort > $tempbase.0 || exit
@@ -348,7 +348,7 @@ if test $with_gettext = yes || test $use_libtool = 1; then
   IFS=$old_IFS
 
   rm -f $tempbase.0 $tempbase.1
-  trap - 1 2 13 15
+  trap - HUP INT PIPE TERM
 fi
 
 # Import from gnulib.
diff --git a/top/bootstrap-funclib.sh b/top/bootstrap-funclib.sh
index f66f338c5a..cfad85a318 100644
--- a/top/bootstrap-funclib.sh
+++ b/top/bootstrap-funclib.sh
@@ -501,7 +501,7 @@ prepare_GNULIB_SRCDIR ()
       elif [ ! -d "$gnulib_path" ]; then
         echo "$0: getting gnulib files..."
 
-        trap cleanup_gnulib 1 2 13 15
+        trap cleanup_gnulib HUP INT PIPE TERM
 
         shallow=
         if test -z "$GNULIB_REVISION"; then
@@ -531,7 +531,7 @@ prepare_GNULIB_SRCDIR ()
           git -C "$gnulib_path" reset --hard FETCH_HEAD
         fi
 
-        trap - 1 2 13 15
+        trap - HUP INT PIPE TERM
       fi
     fi
     GNULIB_SRCDIR=$gnulib_path
diff --git a/top/gitsub.sh b/top/gitsub.sh
index 9a813cf7ba..54c52a874f 100755
--- a/top/gitsub.sh
+++ b/top/gitsub.sh
@@ -354,9 +354,9 @@ func_pull ()
         fi
       else
         # The subdir does not yet exist. Create a plain checkout.
-        trap func_cleanup_current_git_clone 1 2 13 15
+        trap func_cleanup_current_git_clone HUP INT PIPE TERM
         git clone $2 "$url" "$path" || func_cleanup_current_git_clone
-        trap - 1 2 13 15
+        trap - HUP INT PIPE TERM
       fi
       ;;
     esac




reply via email to

[Prev in Thread] Current Thread [Next in Thread]