From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3ts8MPDZ2Grx4AQAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 11:27:44 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UejjAeBc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A7EBA1E051; Wed, 21 Oct 2026 11:27:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3D6711E04D for ; Wed, 21 Oct 2026 11:27:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BE00B4BA2E1A for ; Wed, 21 Oct 2026 15:27:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE00B4BA2E1A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UejjAeBc Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id A90D64BA2E1A for ; Wed, 21 Oct 2026 15:27:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A90D64BA2E1A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A90D64BA2E1A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792596435; cv=none; b=xsD+IenXKENQC2E/WU2vY66MmDpSTqBYGh/khOWohTUTG8kfqda8bQebOAhFWCzwTilyw2DG9l97WT2AcVPmrkd8siMUrhdn1qfLygZiBFORVysTxxC0YiXaWg7Qye+w7kNfVDvxHWzILXAbBKjKth7gMeMeP4PQNYSAxSYFla8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792596435; c=relaxed/simple; bh=DCH4AW27BYHwR0OzpxHtYDwr00HBnS1ZMac7gb3J2v8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=AkwQm9xKU6U5ECOWY0moMXAskaKL7rL2C3LsWf85euVLbyXh2AbUPlgU5X0v8rVdtbbfHscoG/0S0jknuGLgYWkb2Ck/lwL0c4y1qp4zn7LZF2GxHQZbKxc1ogp7vYZDPuRx3GdwzzLXGOx0lObSHDbBmi7T88IJ7rhKRo+Zibo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=UejjAeBc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A90D64BA2E1A Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 69LFR51g187904 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Oct 2026 11:27:10 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 69LFR51g187904 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1792596431; bh=nXUMJ9QY+bq7b7UA+A3pDXS6LP330sE7O0FYrdeSvpk=; h=Date:Subject:To:Cc:From:In-Reply-To:From; b=UejjAeBcgZUd1pG+ZAeo/a6p7KJ0WAw4a7vi5KlkF7vS6QinopvzndWdnxZLFSpnY KqsALV6SseqSCZr2if/M05f8ITi/gUEBRRKjG8S6CVqA3rZO4K8QrwfVuoQRAePAAB K3PJAzyD+pp1Y83MTyxGyWMEBuigVrAvWPaTXir4nxXnTu4O4UVQ9TypPKiSn8NcFk lKteOVcd7Aq1wPGVrpliY1RWXQHyQ/M7NtCih6vmstLsaW5W56FepoRBRVUMVm0OGi ZB4+rt4mS35w/7il+etrlz9klS8d2yTWbSlBPWVveaV2o99EyMZqy/x6x/ESeE1YK/ 7v+s13HS2/2xA== Received: by simark.ca (Postfix) id 543A21E04D; Wed, 21 Oct 2026 11:27:04 -0400 (EDT) Message-ID: Date: Wed, 21 Oct 2026 11:27:01 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Accept ksh88 exit status for SIGINT in shell.exp To: Aditya Vidyadhar Kamath , ulrich.weigand@de.ibm.com, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com References: <20261021091128.28234-2-akamath996@gmail.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20261021091128.28234-2-akamath996@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 21 Oct 2026 15:27:05 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 10/21/26 5:11 AM, Aditya Vidyadhar Kamath wrote: > From: Aditya Vidyadhar Kamath > > 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. I like the idea of testing the actual shell's behavior to set our expectations for what GDB should output. There are just two problems: - Your check uses TCL's exec, which runs on the build machine. That wouldn't be right in a remote-host scenario. I think we can restrict your check to when running with a local host. This assumes that you are not doing remote-host testing with AIX. - The shell and pipe commands don't necessary use the same shell. The shell command reads the SHELL env var, but the pipe command uses popen, which is hardcoded to use /bin/sh. I presume that if you run your patch with bash as your shell, you'd see a failure for the pipe test. Can you test this patch, which addresses those two problems? >From 8065b5c254e1455be868101cd20c18c2a193170a Mon Sep 17 00:00:00 2001 From: Aditya Vidyadhar Kamath Date: Wed, 21 Oct 2026 14:41:29 +0530 Subject: [PATCH] Accept ksh88 exit status for SIGINT in shell.exp 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 a shell_dies_from_sigint proc, which runs "kill -2 $$" with a given shell outside of GDB and looks at the raw wait status. Add check_shell_interrupt_status, which replaces the duplicated checks and expects either the "killed by signal 2" or the "exited with code 130" outcome, based on what shell_dies_from_sigint found. The two commands don't necessarily use the same shell. The "shell" command uses $SHELL, or /bin/sh if it is not set, while the "pipe" command uses popen, which always uses /bin/sh. On AIX with SHELL=/usr/bin/bash, the first is killed by the signal and the second exits with code 130. Check each command against its own shell. The check uses TCL's exec proc, which runs on the build machine, so skip it when the host is remote. If the host is remtoe, expect the shell to be killed by the signal, as before. 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. Change-Id: I2ef115e7095d675baded68595393af8649a9345e --- gdb/testsuite/gdb.base/shell.exp | 57 +++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp index 2e6c63585eb0..de2bfcfe3a26 100644 --- a/gdb/testsuite/gdb.base/shell.exp +++ b/gdb/testsuite/gdb.base/shell.exp @@ -17,6 +17,50 @@ load_lib completion-support.exp +# Not every shell reacts to "kill -2 $$" the same way. Most are killed +# by the signal, but ksh88 (/bin/sh and /usr/bin/ksh on AIX) catches +# SIGINT and exits with status 130 (128 + SIGINT) instead. GDB reports +# what it sees, so in that case $_shell_exitcode is 130 and +# $_shell_exitsignal is void. +# +# Find out which kind of shell SHELL is by running "kill -2 $$" with it +# outside of GDB. Return true if the shell is killed by the signal, and +# false if it exits with status 130. +# +# The check runs on the build machine, so only do it if not using a remote +# host setup. If using a remote host setup, assume the "normal" behavior. + +proc shell_dies_from_sigint { shell } { + if { [is_remote host] } { + return 1 + } + + if { [catch {exec $shell -c {kill -2 $$}} msg opts] } { + set errcode [dict get $opts -errorcode] + if { [lindex $errcode 0] eq "CHILDSTATUS" + && [lindex $errcode 2] == 130 } { + return 0 + } + } + + return 1 +} + +# Check the convenience variables after a shell command that ran +# "kill -2 $$". PREFIX is "shell" or "pipe", and is used to name the +# tests. SHELL is the shell that GDB used to run the command. + +proc check_shell_interrupt_status { prefix shell } { + if { [shell_dies_from_sigint $shell] } { + gdb_test "p \$_shell_exitcode" " = void" "$prefix interrupt exitcode" + gdb_test "p \$_shell_exitsignal" " = 2" "$prefix interrupt exitsignal" + } else { + gdb_test "p \$_shell_exitcode" " = 130" "$prefix interrupt exitcode" + gdb_test "p \$_shell_exitsignal" " = void" \ + "$prefix interrupt exitsignal" + } +} + gdb_exit gdb_start @@ -36,9 +80,14 @@ gdb_test "p \$_shell_exitsignal" " = void" "shell fail exitsignal" # This test will not work when the shell is CMD.EXE. if { ! [ishost *-*-mingw*] } { + # The "shell" command uses $SHELL, or /bin/sh if that is not set. + set shell /bin/sh + if { [info exists ::env(SHELL)] } { + set shell $::env(SHELL) + } + 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" $shell } # Test the $_shell convenience function. @@ -130,8 +179,8 @@ 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" + # The "pipe" command uses popen, which always uses /bin/sh. + check_shell_interrupt_status "pipe" /bin/sh } # Error handling verifications. base-commit: 13db356ae83f72de0828e11826a256a4a28d17b1 -- 2.56.0