* [PATCH] Accept ksh88 exit status for SIGINT in shell.exp
@ 2026-10-15 13:46 Aditya Vidyadhar Kamath
2026-10-20 19:45 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Aditya Vidyadhar Kamath @ 2026-10-15 13:46 UTC (permalink / raw)
To: ulrich.weigand, simon.marchi, tom
Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy, Aditya Vidyadhar Kamath
From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
This patch is in continuation to Simon's patch [1].
gdb.base/shell.exp runs "kill -2 $$" under the shell, through both
"shell" ("!") and "pipe" ("|"), and expects $_shell_exitsignal to be 2
and $_shell_exitcode to be void, that is, a shell that dies from the
signal.
On AIX, /bin/sh and /usr/bin/ksh are ksh88. ksh88 catches SIGINT and
calls exit (130) (128 + SIGINT) instead of dying from the signal. GDB
therefore sees a normal exit, sets $_shell_exitcode to 130 and leaves
$_shell_exitsignal void. This is correct reporting by GDB; the test
assumes a shell that is killed by the signal. The raw wait status of
the shells on AIX 7.3 is:
/usr/bin/ksh exited, code 130
/usr/bin/ksh93 killed by signal 2
/usr/bin/bash killed by signal 2
As a result these four tests failed on AIX:
shell interrupt exitcode
shell interrupt exitsignal
pipe interrupt exitcode
pipe interrupt exitsignal
Add check_shell_interrupt_status, which replaces the duplicated checks.
On AIX it also accepts $_shell_exitcode = 130 together with
$_shell_exitsignal = void.
Tested on AIX 7.3 with a 64-bit GDB: gdb.base/shell.exp now gives
125 passes and no failures. The four tests above failed before.
[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=bf842a2e8d6e9eb7429444904b1b31c8b85d5fb2
---
gdb/testsuite/gdb.base/shell.exp | 49 +++++++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
index 2e6c63585eb..e0f9b9fb1f2 100644
--- a/gdb/testsuite/gdb.base/shell.exp
+++ b/gdb/testsuite/gdb.base/shell.exp
@@ -17,6 +17,49 @@
load_lib completion-support.exp
+# Check the convenience variables after a shell command that ran
+# "kill -2 $$". PREFIX is "shell" or "pipe", and is used to name the
+# tests.
+#
+# Usually the shell dies from SIGINT, so $_shell_exitcode is void and
+# $_shell_exitsignal is 2.
+#
+# On AIX, /bin/sh and /usr/bin/ksh are ksh88. ksh88 catches SIGINT and
+# calls exit (130) (128 + SIGINT) instead of dying from the signal. GDB
+# then sees a normal exit and correctly sets $_shell_exitcode to 130 and
+# leaves $_shell_exitsignal void. Accept that outcome on AIX. Shells
+# that do die from the signal (e.g. ksh93 or bash) still give the usual
+# result, and are accepted as well.
+
+proc check_shell_interrupt_status { prefix } {
+ global gdb_prompt
+
+ set signaled 1
+
+ if { [istarget "*-*-aix*"] } {
+ set test "$prefix interrupt exitcode"
+ gdb_test_multiple "p \$_shell_exitcode" $test {
+ -re " = void\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re " = 130\r\n$gdb_prompt $" {
+ # Expected for ksh88, see the comment above.
+ set signaled 0
+ pass $test
+ }
+ }
+ } else {
+ gdb_test "p \$_shell_exitcode" " = void" "$prefix interrupt exitcode"
+ }
+
+ if { $signaled } {
+ gdb_test "p \$_shell_exitsignal" " = 2" "$prefix interrupt exitsignal"
+ } else {
+ gdb_test "p \$_shell_exitsignal" " = void" \
+ "$prefix interrupt exitsignal"
+ }
+}
+
gdb_exit
gdb_start
@@ -37,8 +80,7 @@ gdb_test "p \$_shell_exitsignal" " = void" "shell fail exitsignal"
# This test will not work when the shell is CMD.EXE.
if { ! [ishost *-*-mingw*] } {
gdb_test_no_output "! kill -2 $$"
- gdb_test "p \$_shell_exitcode" " = void" "shell interrupt exitcode"
- gdb_test "p \$_shell_exitsignal" " = 2" "shell interrupt exitsignal"
+ check_shell_interrupt_status "shell"
}
# Test the $_shell convenience function.
@@ -130,8 +172,7 @@ gdb_test "p \$_shell_exitsignal" " = void" "pipe fail exitsignal"
# This test will not work when the shell is CMD.EXE.
if { ! [ishost *-*-mingw*] } {
gdb_test "|p 123| kill -2 $$" ""
- gdb_test "p \$_shell_exitcode" " = void" "pipe interrupt exitcode"
- gdb_test "p \$_shell_exitsignal" " = 2" "pipe interrupt exitsignal"
+ check_shell_interrupt_status "pipe"
}
# Error handling verifications.
--
2.51.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Accept ksh88 exit status for SIGINT in shell.exp
2026-10-15 13:46 [PATCH] Accept ksh88 exit status for SIGINT in shell.exp Aditya Vidyadhar Kamath
@ 2026-10-20 19:45 ` Simon Marchi
2026-10-21 9:08 ` Aditya Kamath
2026-10-21 16:33 ` Tom Tromey
0 siblings, 2 replies; 5+ messages in thread
From: Simon Marchi @ 2026-10-20 19:45 UTC (permalink / raw)
To: Aditya Vidyadhar Kamath, ulrich.weigand, tom
Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy
On 10/15/26 9:46 AM, Aditya Vidyadhar Kamath wrote:
> From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
>
> This patch is in continuation to Simon's patch [1].
>
> gdb.base/shell.exp runs "kill -2 $$" under the shell, through both
> "shell" ("!") and "pipe" ("|"), and expects $_shell_exitsignal to be 2
> and $_shell_exitcode to be void, that is, a shell that dies from the
> signal.
>
> On AIX, /bin/sh and /usr/bin/ksh are ksh88. ksh88 catches SIGINT and
> calls exit (130) (128 + SIGINT) instead of dying from the signal. GDB
> therefore sees a normal exit, sets $_shell_exitcode to 130 and leaves
> $_shell_exitsignal void. This is correct reporting by GDB; the test
> assumes a shell that is killed by the signal. The raw wait status of
> the shells on AIX 7.3 is:
>
> /usr/bin/ksh exited, code 130
> /usr/bin/ksh93 killed by signal 2
> /usr/bin/bash killed by signal 2
>
> As a result these four tests failed on AIX:
>
> shell interrupt exitcode
> shell interrupt exitsignal
> pipe interrupt exitcode
> pipe interrupt exitsignal
>
> Add check_shell_interrupt_status, which replaces the duplicated checks.
> On AIX it also accepts $_shell_exitcode = 130 together with
> $_shell_exitsignal = void.
>
> Tested on AIX 7.3 with a 64-bit GDB: gdb.base/shell.exp now gives
> 125 passes and no failures. The four tests above failed before.
>
> [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=bf842a2e8d6e9eb7429444904b1b31c8b85d5fb2
> ---
> gdb/testsuite/gdb.base/shell.exp | 49 +++++++++++++++++++++++++++++---
> 1 file changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
> index 2e6c63585eb..e0f9b9fb1f2 100644
> --- a/gdb/testsuite/gdb.base/shell.exp
> +++ b/gdb/testsuite/gdb.base/shell.exp
> @@ -17,6 +17,49 @@
>
> load_lib completion-support.exp
>
> +# Check the convenience variables after a shell command that ran
> +# "kill -2 $$". PREFIX is "shell" or "pipe", and is used to name the
> +# tests.
> +#
> +# Usually the shell dies from SIGINT, so $_shell_exitcode is void and
> +# $_shell_exitsignal is 2.
> +#
> +# On AIX, /bin/sh and /usr/bin/ksh are ksh88. ksh88 catches SIGINT and
> +# calls exit (130) (128 + SIGINT) instead of dying from the signal. GDB
> +# then sees a normal exit and correctly sets $_shell_exitcode to 130 and
> +# leaves $_shell_exitsignal void. Accept that outcome on AIX. Shells
> +# that do die from the signal (e.g. ksh93 or bash) still give the usual
> +# result, and are accepted as well.
> +
> +proc check_shell_interrupt_status { prefix } {
> + global gdb_prompt
> +
> + set signaled 1
> +
> + if { [istarget "*-*-aix*"] } {
> + set test "$prefix interrupt exitcode"
> + gdb_test_multiple "p \$_shell_exitcode" $test {
> + -re " = void\r\n$gdb_prompt $" {
> + pass $test
> + }
> + -re " = 130\r\n$gdb_prompt $" {
> + # Expected for ksh88, see the comment above.
> + set signaled 0
> + pass $test
> + }
> + }
> + } else {
> + gdb_test "p \$_shell_exitcode" " = void" "$prefix interrupt exitcode"
> + }
What is the value of the SHELL env var with ksh88? Instead of doing an
"aix" check, would you be able to tell from that variable that the shell
is ksh88, and update expectations accordingly?
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] Accept ksh88 exit status for SIGINT in shell.exp
2026-10-20 19:45 ` Simon Marchi
@ 2026-10-21 9:08 ` Aditya Kamath
2026-10-21 16:33 ` Tom Tromey
1 sibling, 0 replies; 5+ messages in thread
From: Aditya Kamath @ 2026-10-21 9:08 UTC (permalink / raw)
To: Simon Marchi, Aditya Vidyadhar Kamath, Ulrich Weigand, tom
Cc: gdb-patches, SANGAMESH MALLAYYA
[-- Attachment #1: Type: text/plain, Size: 375 bytes --]
Hi Simon,
>What is the value of the SHELL env var with ksh88? Instead of doing an
>"aix" check, would you be able to tell from that variable that the shell
>is ksh88, and update expectations accordingly?
# env | grep SHELL
SHELL=/usr/bin/ksh
It is ksh. Yes, we can use that. Sending you a v2 version of this patch with the same.
Thanks and regards,
Aditya.
[-- Attachment #2: Type: text/html, Size: 1350 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Accept ksh88 exit status for SIGINT in shell.exp
2026-10-20 19:45 ` Simon Marchi
2026-10-21 9:08 ` Aditya Kamath
@ 2026-10-21 16:33 ` Tom Tromey
2026-10-21 16:42 ` Simon Marchi
1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-10-21 16:33 UTC (permalink / raw)
To: Simon Marchi
Cc: Aditya Vidyadhar Kamath, ulrich.weigand, tom, gdb-patches,
Aditya.Kamath1, sangamesh.swamy
Simon> What is the value of the SHELL env var with ksh88? Instead of doing an
Simon> "aix" check, would you be able to tell from that variable that the shell
Simon> is ksh88, and update expectations accordingly?
I was wondering whether the test should simply unconditionally allow
either value, since they both seem valid in some sense and since this
would avoid having to maintain a list of which shell does what.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Accept ksh88 exit status for SIGINT in shell.exp
2026-10-21 16:33 ` Tom Tromey
@ 2026-10-21 16:42 ` Simon Marchi
0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2026-10-21 16:42 UTC (permalink / raw)
To: Tom Tromey
Cc: Aditya Vidyadhar Kamath, ulrich.weigand, gdb-patches,
Aditya.Kamath1, sangamesh.swamy
On 10/21/26 12:33 PM, Tom Tromey wrote:
> Simon> What is the value of the SHELL env var with ksh88? Instead of doing an
> Simon> "aix" check, would you be able to tell from that variable that the shell
> Simon> is ksh88, and update expectations accordingly?
>
> I was wondering whether the test should simply unconditionally allow
> either value, since they both seem valid in some sense and since this
> would avoid having to maintain a list of which shell does what.
>
> Tom
If we're not afraid that it could hide a real GDB bug (which is unlikely
I suppose), sure.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-21 16:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 13:46 [PATCH] Accept ksh88 exit status for SIGINT in shell.exp Aditya Vidyadhar Kamath
2026-10-20 19:45 ` Simon Marchi
2026-10-21 9:08 ` Aditya Kamath
2026-10-21 16:33 ` Tom Tromey
2026-10-21 16:42 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox