From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gSCxDVXZ0GokkhEAWB0awg (envelope-from ) for ; Thu, 15 Oct 2026 09:47:01 -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=lw3EsBfo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 325E41E050; Thu, 15 Oct 2026 09:47:01 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.9 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,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 79C051E04E for ; Thu, 15 Oct 2026 09:46:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 046BB4BA798C for ; Thu, 15 Oct 2026 13:46:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 046BB4BA798C 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=lw3EsBfo Received: from mail-dy1-x1330.google.com (mail-dy1-x1330.google.com [IPv6:2607:f8b0:4864:20::1330]) by sourceware.org (Postfix) with ESMTPS id 1EF184BA23DD for ; Thu, 15 Oct 2026 13:46:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EF184BA23DD 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 1EF184BA23DD Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792071989; cv=none; b=eA6IfCCg12FXR/yLw98OaRu0c0PI22L26c0XDAQBzwPLUZsusQNW2gvXCYGlES/pqzHL8eyowRzqO9/kS++g73qy93Lp+yw+79aLW0IMBOxYCd1557d8CToAG0rlyhEeh/D1kIqVjIMILlZ5NB+MX+4oUjH6JPT3ZQ5TtxwWRvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792071989; c=relaxed/simple; bh=X9ip7V53oPdynPyT7kFXEqkXFOI43+kYFaR92k7wH5Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=B9bqHC6yiF2sdXU3xKa+wQxjvugv3DtBfleMhVGB1NbCbz6LQaWbhtyYuCZThfPi3+/2jIJG4b7npEdTK2/r+bqEtj6ZcazkKKlwNkCZagTekkqOG8VV3YErULLGfgoWBIkYfnZ2Kx600AUa+8xjZ8+Ul6STfiEi3RIRTgWDg0k= 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=lw3EsBfo DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EF184BA23DD Received: by mail-dy1-x1330.google.com with SMTP id 5a478bee46e88-35ef6b49813so1817897eec.0 for ; Thu, 15 Oct 2026 06:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792071988; x=1792676788; 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=Rtvh6WbnfrlHTprqqBQg3Teyi04mX23fagp4UEY2qJo=; b=lw3EsBfoUlUNm0ThJqLqv3vfGfivuML06kE8aEkTt52zeuzMWy8e1Yww0sY5kbdDeu CjcoRJACow2B3nrOaI3wfVbH0FkNantzfOeImUh3dQIP/GciwW+n1/mNrD7CsE78t/H5 cPQjW+V0nXmGZW6FsDOA3ftfOsq4IIRdV2G+FIrqovhQVw6x3mwBoH+R7m6doyEBlJw6 dL4cUOzoZ8YiqmPyorEhpvdOyDm9K1B/TvP+WVAAqPJV2JTUgS8HUItUpE7JF4P3Xjpb L0VB1TGqC361Mnnh+UpfwnLHgN3Lg7B3CjD8ZOBCI0wB23fguWPLUCdYOhYeZIGDCfm9 A+1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792071988; x=1792676788; 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=Rtvh6WbnfrlHTprqqBQg3Teyi04mX23fagp4UEY2qJo=; b=sk2uS+C/e/qQ1O9mukMlDstMUjzdM48x5CZjCQqyzpFzHVo6Dt13zaFLZsXUxTS5Ws p46uoLwm0VQSQSc+QY4ZeUCUN5/heuFbFcXs3mE+IUFEpOIBnELkGx7+HupQRVxXni8y lnYBerTTsKh9YGthQzkM1ZKw5Owyo2/pabtexkFMqC3p/7Vn2SL/RWHGZLtNsAckAdvZ yNbK/oilyWz8ns5VRo3QAcPy/r9samezF7ObXBNnGkSwALgC/rMAJwj6uFGq2I4eMxUZ HV6/21ecSzw9ucxwepuXuYcH/+RBNwqOZAoeYtknOlY9jqfL7d/p3UCQ/DFa0pl7Hrya v7gw== X-Gm-Message-State: AFq9FYJd9MurjLLXHf9F3UdAvkIxwqIHeZ2qkcB6y5Y0Mbjn/IKjRRi2 XJGACaWs/qdI31w4D2mXhvpUevG0v+PjR9T0N3TEuJ4sphW3BHBPBanH X-Gm-Gg: AYBFou2WPW0cEE9TspgpHDC/kgzfsCWFdZKtZqkyxnSV/y8iOaxUhFL66zMWBTlpbwD IoyN6xAWe7G/e6N+y4x2W09wQ5neTdOL+XEShAVEnJ37CPvcPynemApzsVZtOk+VLeRAT5IdVdz YxVCBRyMleXrkLJ713P3oXcqp1YVcqsuYtBhOnJoits3clT9QqhIS1G+RCZFIP8gjeuQx/ib8we vbTOaawOKrxu5AzJhON5MBvLma1BDtONlb/rVJivfiLc7q5ZZg2RuuPBmEF8Cni/4tFIdcuiuva wPNGSMOS7MlHnA6Dy/JNnDMQKexq8rC3AnFCUbidTZbqJP6Ius/Bsiv6uCYsp27tBQj3F57ztKF 9G4WSRKg2cKFHphtYCz21gvtsbFUwneKwkObbuZuV0/FIe96gDMtiLeBnc0VDjsercDT99FNVtP jObc73eEcpke5EUHF3dH+T6P6arrkbq1+/PVvkDoiKdSdShngpiJJXukpdOZ5d3xtmdPIKjckvf srbjrVj5JnsZ4hWnpyqM4h+9cg= X-Received: by 2002:a05:693c:41c5:20b0:35c:ba31:6fef with SMTP id 5a478bee46e88-35cba3173b2mr10246671eec.36.1792071986391; Thu, 15 Oct 2026 06:46:26 -0700 (PDT) Received: from localhost.localdomain ([122.171.22.226]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3537cb2954bsm65040976eec.26.2026.10.15.06.46.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 15 Oct 2026 06:46:25 -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] Accept ksh88 exit status for SIGINT in shell.exp Date: Thu, 15 Oct 2026 19:16:05 +0530 Message-ID: <20261015134604.81658-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, 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