Pádraig Brady <[email protected]> writes:
> On 29/12/2025 21:53, Collin Funk wrote:
>> Pádraig Brady <[email protected]> writes:
>>
>>> Well all of the above is testing kill(1),
>>> and posix doesn't specify name -> number support,
>>> so I'm not sure framework_failure is appropriate here.
>>>
>>> Couldn't we just exclude kill(1) here.
>>> I.e., not do any of the above,
>>> and just pass "RTMIN' and "RTMAX" to env, like:
>>>
>>> if test $SIGRTMIN -gt 0 && test $SIGRTMAX -gt $SIGRTMIN; then
>>> for sig in 'RTMIN' 'RTMAX'; do
>>> ...
>>> done
>>> fi
>> POSIX requires that the range SIGRTMIN to SIGRTMAX are reserved for
>> real-time signals, not that any of them (including SIGRTMIN and
>> SIGRTMAX) are supported signal numbers. So that code just finds the
>> highest and lowest and uses them.
>> That is probably a theoretical issue, though. Let me do some
>> experimenting on the cfarm machines to check if SIGRTMIN and SIGRTMAX
>> are valid signal numbers.
>
> Right. I can't see that if they're defined, they wouldn't be supported.
>
>> BTW, that file uses require_bash_as_SHELL_. So we should be getting the
>> 'kill' builtin from bash. Maybe some old versions don't support that
>> syntax though, I am not sure.
> Oh right. That deserves a comment at least.
>
> Also we could rely on the fact that if bash supports `kill -l RTMIN RTMAX`,
> then env should be able to support those names, though it's probably
> fine for env to use those names once the defines are present.
That sounds good to me. I pushed the attached patch which simplifies it
to just use 'kill -l RTMIN RTMAX' and added a comment above
"require_bash_as_SHELL_" to prevent one of us from removing it.
I didn't do too much experimenting on cfarm after noticing AIX's strange
behavior:
$ ssh cfarm119.cfarm.net
$ type kill
kill is a shell builtin.
$ kill -l RTMIN RTMAX
ksh: kill: 0403-010 A specified flag is not valid for this command.
$ /bin/kill -l RTMIN RTMAX
0509-051 invalid exit status value
$ sleep 100 &
[1] 32309712
$ kill -s RTMIN 32309712
ksh: kill: 0403-010 A specified flag is not valid for this command.
$ /bin/kill -s RTMIN 32309712
0509-050 The specified signal number or name is not valid.
Usage: kill [ -SignalNumber|-SignalName|-s [SignalName|SignalNumber]]
{ProcessID}...
Usage: kill -l [exit_status]
$ bash
$ kill -l RTMIN RTMAX
50
57
So, AIX 7.3 supports real-time signals but /bin/sh has a 'kill' builtin
that doesn't understand them and /bin/kill doesn't understand them. So I
think my v1 patch would fail here, but v2 should pass since bash's
builtin works.
I might follow up with the POSIX people on this. It seems strange to not
require 'kill -s' to support real-time signals if the system supports
them. But the current specification doesn't [1].
Collin
[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/kill.html
>From d3f0c7290270babb2fb855ff82c66d15345e83f4 Mon Sep 17 00:00:00 2001
Message-ID: <d3f0c7290270babb2fb855ff82c66d15345e83f4.1767072885.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 28 Dec 2025 19:48:29 -0800
Subject: [PATCH v2] 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.
---
tests/env/env-signal-handler.sh | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/env/env-signal-handler.sh b/tests/env/env-signal-handler.sh
index 77d556457..981a87319 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 <<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 \
--
2.52.0