From: Collin Funk Date: Mon, 29 Dec 2025 03:48:29 +0000 (-0800) Subject: tests: env: check that real-time signals can be ignored X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3f0c7290270babb2fb855ff82c66d15345e83f4;p=thirdparty%2Fcoreutils.git tests: env: check that real-time signals can be ignored * 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. --- diff --git a/tests/env/env-signal-handler.sh b/tests/env/env-signal-handler.sh index 77d5564578..981a87319e 100755 --- a/tests/env/env-signal-handler.sh +++ b/tests/env/env-signal-handler.sh @@ -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 <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 <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 \