From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dTOAJKmy2WqDdQoAWB0awg (envelope-from ) for ; Thu, 22 Oct 2026 02:52:25 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IPzOKjaP; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 72D0C1E051; Thu, 22 Oct 2026 02:52:25 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 DFDEC1E047 for ; Thu, 22 Oct 2026 02:52:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 800C14BA2E22 for ; Thu, 22 Oct 2026 06:52:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 800C14BA2E22 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IPzOKjaP Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id BCDAB4BA2E22 for ; Thu, 22 Oct 2026 06:51:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCDAB4BA2E22 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BCDAB4BA2E22 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792651917; cv=none; b=DzQi0B4NtbPBpMSMp0Jaxl4L0jf3D3hJyd7V1qhFU9BScS4rIVWVskHIUlBIlqllJj9le8jBU9gDOodQTx59PkoiQgs63Il1EVQMFjOrnL5oLLkuIw5jH9sHKSFU6IUl9Y+12wqTEkEwyMd/klN3Q8d485TzTM7d6rfcb6cq97Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792651917; c=relaxed/simple; bh=AXNX0hqPQLZMlXpU/3JMDLzKDd4yJ1geLkBoMY0zG90=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=D/IVyZL1ytY/bNSXDjlvxJJ7oabv9hyw3NONrTx+BSiV3b9GMoZBl+16Nt+8KS5ijxc5MRahIL0pHGiByHlxeNJo9fevikCzbm5VbmZe7hVe1eCloRbKBVp/mLKfizDwf5QmylV1R+mXr4w/Y0/LiU/rDv6jAuICP2Vec43d+kc= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IPzOKjaP DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCDAB4BA2E22 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-8a06cc097c7so957192b3a.0 for ; Wed, 21 Oct 2026 23:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792651917; x=1793256717; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=d5tXq6lXrLXSmwJru/3dl7PG9PHuuI2Q7ShrqP+NZDk=; b=IPzOKjaP34Zb1Il+UMHzD87WIOZTBNyoYuVSRnk+oPYk+aoKscW0rGllxlhWURF889 jce43nXZq51OpTWz7MEQ8QKsnyg8usFXAT3MXFTuIJ7XciqsNbIwN7hWNSt3QFhLLOCV XYKPbABgCehJ2QzMdsIKKyQZI4mMJVPwGmB3tkI2aTc5pX8c97WLSNxH2Fji2tZwubo/ EDc2M5mjFEhnoTYcdM2MeSyD9nykjJmwxuJZt6pKnHX//Q6T+ALHKLnULTg7O4XG8nt9 Oc3CqpOLbKa5D7l6GjUJF8k6xNRxblk0YP/vh+KU892YLWLfRC7TlzQxc+bcwSLVDb8d bBig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792651917; x=1793256717; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=d5tXq6lXrLXSmwJru/3dl7PG9PHuuI2Q7ShrqP+NZDk=; b=yq1baiUCumTO4tQjSeOcShKPY+ankGiATaYxFI6+KmOrPKE+/vvzlnLWfsS3d4w9IC c1cAg2kiDuN4OjZy5pUceyBCMIdXqQcitH+aPp3E5Lp3bPxqn5n61ImnAR4XXv97Kcdo LgJKPn9BkXVjhl0CgSYFeAS0r0mGVf+LgcvG9MBOq3JkvcAtaaeqxJQvDAJiUTFLIVQi 1rw+ij3cQ903kZEgI1R4bxbLnn2gsCWpOerxVDU9FAzlyatSJHejnY2cXFI1QTEiloNQ 69Hbw7yB7W5TXQNggWqsfouZiIltf9rjInftS0yJ+K93k7GHKNyzZ0qAMJBkI0W5987U WoRg== X-Gm-Message-State: AFq9FYJpDCs076AfhE25gQ1vKClq69uiU1JtMvPjrlyVr95GsDzCI8uY 4WGfhlMHiK0aEXxJ9eAyRYxoMMrLDsM8TiKdq39FwMRVrWnqX7cbF6rA X-Gm-Gg: AYBFou1r44SP9IxIKu5uyW6Ewm0DEgTZ4EmS4BlA8jKD4x9MxLZnNe7JH+CBNGZZ8XN e0Tvj2ai8uYm0qvmdFS81iU2MCamYoy9h5GZKMgaZoN89q+Y9MHWnN9k+zaOlPAOBLgKzgNuALT Ktt/YcLbg//2h9ZKXoVj+/48Od+3Ua3ut3DVPGrSH3tZA7oEM8sTjGsw8z8m1ttfP7XRcFSVBGy NxDQYt1M8bPaAey/22qBOMbBYOlhnVlz2IPgbQ5HOE/7aKzqiOvmgZ7Y4eB3nrYnLS/0D4U2A4N I50wz3Hw+ffkmSND4OpylYElHsCnXHt/7NmJmOdKE/fCw8oKUkph1/kAG/oogbG9wyhypvSiGRs b2ddVr+ptsRrlBx1jzgIR07pbvW9SUik/GlV1XFo13ry6GIozdZLVfS72uGmwK4fWgsrr4ROS7Y 4iaoschswljw6D6n/S2+meSBgA8S4diMnUQq6Rkz96ymy3BO3BDqDwc1w4vn1zxY2J1EAqhsQQJ RjIZmX3ZdK1fxZlMkgwtEkDU+A8Quh61go0MPZzpFjim4u4h97Ix3J/qs9UBIhLQG8a21JB6sYf nOQk8R2peEqCu0+TTQ== X-Received: by 2002:a05:6a20:2593:b0:3e1:d9ff:415e with SMTP id adf61e73a8af0-3e287ead65emr3894444637.44.1792651916652; Wed, 21 Oct 2026 23:51:56 -0700 (PDT) Received: from dhcp-9-123-1-12.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cd6b8052708sm825724a12.3.2026.10.21.23.51.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 21 Oct 2026 23:51:56 -0700 (PDT) From: Aditya Vidyadhar Kamath To: ulrich.weigand@de.ibm.com, simon.marchi@polymtl.ca, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com, Aditya Vidyadhar Kamath Subject: [PATCH v3] Accept ksh88 exit status for SIGINT in shell.exp Date: Thu, 22 Oct 2026 12:21:38 +0530 Message-ID: <20261022065137.34658-2-akamath996@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 and shell_dies_from_sigint: - For "shell", the probed shell is $SHELL (or /bin/sh if not set). - For "pipe", the probed shell is /bin/sh (since popen(3) hardcodes /bin/sh). - If testing with a remote host ([is_remote host]), skip the local Tcl exec probe and assume the shell dies from SIGINT. On shells like AIX ksh88, it accepts $_shell_exitcode = 130 together with $_shell_exitsignal = void. Tested on AIX 7.3 with a 64-bit GDB under ksh88, ksh93, and bash: gdb.base/shell.exp gives 125 passes and no failures. [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=bf842a2e8d6e9eb7429444904b1b31c8b85d5fb2 --- gdb/testsuite/gdb.base/shell.exp | 59 +++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp index 2e6c63585eb..e1a3fe85d29 100644 --- a/gdb/testsuite/gdb.base/shell.exp +++ b/gdb/testsuite/gdb.base/shell.exp @@ -17,6 +17,59 @@ 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 we have by running it the same way GDB +# would. Return true if the shell is killed by the signal, and false if +# it exits with status 130. + +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. + +proc check_shell_interrupt_status { prefix } { + if { $prefix eq "shell" } { + set shell /bin/sh + if { [info exists ::env(SHELL)] } { + set shell $::env(SHELL) + } + } elseif { $prefix eq "pipe" } { + # pipe uses popen, which hardcodes /bin/sh. + set shell /bin/sh + } else { + error "Unknown prefix: $prefix" + } + + 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 @@ -37,8 +90,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 +182,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