]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: env: check that real-time signals can be ignored
authorCollin Funk <collin.funk1@gmail.com>
Mon, 29 Dec 2025 03:48:29 +0000 (19:48 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Tue, 30 Dec 2025 05:26:22 +0000 (21:26 -0800)
* tests/env/env-signal-handler.sh: Test that --ignore-signal with no
options also ignores real-time signals. Test that real-time signals can
be ignored by explicitly listing them.

tests/env/env-signal-handler.sh

index 77d55645781844aa758507595dccc7de4d30c747..981a87319e14c2c5860b4c8d438247bb4479ab60 100755 (executable)
@@ -23,6 +23,8 @@ trap_sigpipe_or_skip_
 # /bin/sh has an intermittent failure in ignoring SIGPIPE on OpenIndiana 11
 # so we require bash as discussed at:
 # https://lists.gnu.org/archive/html/coreutils/2020-03/msg00004.html
+# This test also relies on bash's 'kill' builtin which allows the signal name
+# "RTMIN" and "RTMAX" if those real-time signals are supported.
 require_bash_as_SHELL_
 
 # Paraphrasing https://bugs.gnu.org/34488#8:
@@ -128,6 +130,33 @@ EOF
 timeout_sig=PIPE env_opt='--ignore-signal=PIPE' \
   retry_delay_ env_ignore_delay_ .1 6 || fail=1
 
+if kill -l RTMIN RTMAX; then
+  for sig in RTMIN RTMAX; do
+    # Baseline test - ignore signal handler
+    # -------------------------------------
+    # Terminate 'sleep' with $sig
+    # All real-time signals terminate the program by default.
+    cat <<EOF >exp || framework_failure_
+timeout: sending signal $sig to command 'env'
+EOF
+    timeout_sig=$sig env_opt='' \
+      retry_delay_ env_ignore_delay_ .1 6 || fail=1
+
+    # env test - ignore signal handler
+    # --------------------------------
+    # Use env to ignore $sig - "sleep" should continue running
+    # after timeout sends $sig, and be killed using SIGKILL.
+    cat <<EOF >exp || framework_failure_
+timeout: sending signal $sig to command 'env'
+timeout: sending signal KILL to command 'env'
+EOF
+    timeout_sig=$sig env_opt="--ignore-signal=$sig" \
+      retry_delay_ env_ignore_delay_ .1 6 || fail=1
+    timeout_sig=$sig env_opt='--ignore-signal' \
+      retry_delay_ env_ignore_delay_ .1 6 || fail=1
+  done
+fi
+
 # env test --list-signal-handling
 for sig in INT PIPE; do
   env --default-signal --ignore-signal=$sig --list-signal-handling true \