1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-11 18:02:13 +02:00

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.
This commit is contained in:
Collin Funk
2025-12-28 19:48:29 -08:00
parent d45598f237
commit d3f0c72902

View File

@@ -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 \