From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0U/oAfCB2GqOoAEAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 05:12:16 -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=eglLOsN3; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 02F861E051; Wed, 21 Oct 2026 05:12:16 -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 5DBEE1E047 for ; Wed, 21 Oct 2026 05:12:15 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6BE44BA23DD for ; Wed, 21 Oct 2026 09:12:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6BE44BA23DD 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=eglLOsN3 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 6B00C4BA2E1E for ; Wed, 21 Oct 2026 09:11:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B00C4BA2E1E 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 6B00C4BA2E1E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792573907; cv=none; b=fkcWothCuDMN9weWzfEQvA78BXl4Qvib27P/liHWa2Ro1hfvvP7N1fFFHpwMmKQFFsnKueaTcemjF/ivzWwddGhYbm2qrjwSpIyfg67rGWZ3T8BBpCt8b0h9lo7EY4Fz9esnlUPJcze7Kx764M5bvSCHq2LXLx03cwS15Wh8khs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792573907; c=relaxed/simple; bh=QEHY+MXbI0pSIUgwEGFFtIjFFz8H7mkCh0bFifCp524=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hst/hXTdztdUDyfL57m0AhvCRa/1cdbBGQsKL+Y2bwpBVCcmWmdx6+0yZ1pyd6Od5Uq12MJoV0bTdWKkrKwKCuHVFCZpQtCTqMKzzRTXEjfcNoYVdArEcgMgbdgyBcHsHjggzC42pUwtc4cxb8BDgUV3WgcDyIRJhhWYzHXyGCw= 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=eglLOsN3 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B00C4BA2E1E Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-3a4b3ac8fb7so283010a91.0 for ; Wed, 21 Oct 2026 02:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792573906; x=1793178706; 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=NpudrlixrBoBm08ENdMooPH6yXK+SD1/uy9ZORLSAjA=; b=eglLOsN3iclb39enL1DMYBm2ZSO+qQxp5WdgcfT1S09LJ/Wr2JgYQqZ9olMyogmN9z I/xg6DsHdlpuvgFrWIYb3XxIDi8JZq8ORCs6LkjiEC6CWZ5R8YES7AvigKEvAyA63t1I QVQtUVo3BWLJnAX5QZQbdgDywSnMpYjoR4maKODwihkq+6/PffsY2+ioYeTLbLNowlLW +BnNUfOpr8xgMwwaEZ9nTENSD2IccGi/4bVxVEQ3ZvEMbkJFeLNz8rNZxU6fqJ8q2VVb DJ0H35f2+ph495vxXxpG5iAndjY1rgJZcR/G+7gimLPAA1LXuZkUlQfXn0oyuHLl6Kon FmKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792573906; x=1793178706; 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=NpudrlixrBoBm08ENdMooPH6yXK+SD1/uy9ZORLSAjA=; b=bLlDyBeIHoTe6SQuXaAhh5ny+3nay5OiOIEbj4ZblzMPgAKB6pKeFRxTVrjP7GFIXH /C3tc6dsZwjxT1VuT9nBn6MzJ+SQWkrrgBQb9yIdPO8x072D9BDG738+pGOXqbD0Xw0v /OoLrA6aCrmtfzHEC1fAfhCaOp1n3Mf79mplMTGNHBdC+7/SFLFLaLZcXlGxQ9ibd6nq Eug5iNJ4Q70wckixU4qnO5h3sURZGQkkUDL9Yz5uem3W/gc5iriyAYjsbswYsXNIvH/b Vqj98kKG/RdB00e/sCYSsatrxNx3inBehVljineRVSFGP4QmLqL7WWtkuJvLv9KgflWz GVZg== X-Gm-Message-State: AFq9FYIefzJKZBk2IC9955AhFxPksU79vvLl1Ga7IOsMg7bwaEHbDaK3 HEgbCBN15SEShUmG1sf2sjKMrtJG9WX6XyE7UgzfalNKpS6i4Opdf/bS X-Gm-Gg: AYBFou0WqZCkd7bsZG3SMAmvK4URGbwi5RFr0h2NTLHBYhrFURXnrGoQ28lN2NAh/hb 7X7rXWt3d6rGV/5dpDSouU+SDKpnwDEd4EpwPET+zBN4k2aus4t7eCEQ6Qr4Ir2Zd5uU3/xKF0C YvvIPEjSmW5v0m4tgYhCaT6b+vG4O/P3MsdV/0FVUl5ag7gwIacKcsPxO3iX9NVkq4tMgkHmBGw Qx08qTQmiuYj6jusAj87eiy6b4dD2AL9aV7hQLhvAlfT/DsP1IEbi5ck9dmSRNx+Al23HxB1lPV M4fmgzK9llj2640bAhGAsYQTAOlo4nnlnVxMj56Tr8umntn49nPDK890z6oVpMg1CW7RU61HF+y mfbwMa4MfdXBkYh3As3HDAtbC/SUHI6phuT9IqDJQUnN7ZhysxvaKazWekAyxohRrRy5rc5zYBk BostTeeGyVnoE7b7ky50m9io7CknBqFhABLZhA7WUJps6I99Vzf/cep3VE014fFLUGpWpR7rxjO O/Z1GG1iN82NNA2bHkvlO78Dnpzmkpb1GyiV5gYq1DINLXWYoKYMqAAJTvLCv2c1AD6ExvTU0tg nBjnOaynA9spRXfB6A== X-Received: by 2002:a17:90b:57e8:b0:3ab:3675:8ed with SMTP id 98e67ed59e1d1-3ad86c7ab3amr1325373a91.22.1792573906311; Wed, 21 Oct 2026 02:11:46 -0700 (PDT) Received: from dhcp-9-123-1-12.bl1-in.ibm.com ([129.41.58.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ad813dfa5fsm3279722a91.14.2026.10.21.02.11.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 21 Oct 2026 02:11:46 -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 v2] Accept ksh88 exit status for SIGINT in shell.exp Date: Wed, 21 Oct 2026 14:41:29 +0530 Message-ID: <20261021091128.28234-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 | 48 +++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp index 2e6c63585eb..a72444f45ff 100644 --- a/gdb/testsuite/gdb.base/shell.exp +++ b/gdb/testsuite/gdb.base/shell.exp @@ -17,6 +17,48 @@ 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 ($SHELL, or /bin/sh if that is not set). Return true if the +# shell is killed by the signal, and false if it exits with status 130. + +proc shell_dies_from_sigint {} { + set shell /bin/sh + if { [info exists ::env(SHELL)] } { + set shell $::env(SHELL) + } + + 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 { [shell_dies_from_sigint] } { + 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 +79,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 +171,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