From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Masahiro Yamada Newsgroups: gmane.emacs.help Subject: Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that? Date: Sun, 27 Jun 2021 21:25:38 +0900 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20833"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 27 14:27:34 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lxTsq-00059r-JI for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 27 Jun 2021 14:27:33 +0200 Original-Received: from localhost ([::1]:53056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxTso-0005MT-ET for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 27 Jun 2021 08:27:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxTsG-0005M5-Et for help-gnu-emacs@gnu.org; Sun, 27 Jun 2021 08:26:57 -0400 Original-Received: from conssluserg-06.nifty.com ([210.131.2.91]:43196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxTsC-0003P4-Uk for help-gnu-emacs@gnu.org; Sun, 27 Jun 2021 08:26:55 -0400 Original-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 15RCQF2P019346 for ; Sun, 27 Jun 2021 21:26:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 15RCQF2P019346 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1624796775; bh=3NiwMZcZZ3xWOHGr3okotr2gJohEIIHZDenAmE/v9sM=; h=From:Date:Subject:To:From; b=12s10NW3xjGkdYWC8vTNFhlG0JqFqTIcihvQiLM1XZjw2UafWkiPkhMELtX+dblIZ wp/e6OQ7nSvBFOq6VNsl+qszv3usXbMvDj9+UnzOKcEPX8LAbf4GxR0QXuFUWn8ub0 2nmPzcxu21Tzg166OQblfonZf51pvHvr4atO+vZ4tUvqjSNpopu9Wmy7A7/LG7AOR+ dGS/34knOErnnvg5h+E9L+Hzm2qB225PMePNqisDhNFup1dDCUHN2HmrZuPWOA/Law 2Kxld67iAqjiPKnfhTrpTi5zeA2k/42ES+pxrZ/tIZ9fKZpNnAHJkTqbseGx3q8sq9 h/ak4WGTgQkmw== X-Nifty-SrcIP: [209.85.214.174] Original-Received: by mail-pl1-f174.google.com with SMTP id b3so7297401plg.2 for ; Sun, 27 Jun 2021 05:26:15 -0700 (PDT) X-Gm-Message-State: AOAM532oYZEchTX7akMLbOaX7aSch1L/3Q+0iEP71RvtyI8awVkbbA5U KslVBXZ14/5FFkgFQKIlNWa6XVpajV3CuCRQYvY= X-Google-Smtp-Source: ABdhPJyYHEvdVP8kIWxYYqnaWPLfZBkLOcmJwHUK6/I8IioJQakrcmbrPYTxK9lbDuXIozN/bAeHQqciYozqfrYVH8w= X-Received: by 2002:a17:90a:c506:: with SMTP id k6mr32009720pjt.198.1624796774665; Sun, 27 Jun 2021 05:26:14 -0700 (PDT) X-Gmail-Original-Message-ID: Received-SPF: softfail client-ip=210.131.2.91; envelope-from=masahiroy@kernel.org; helo=conssluserg-06.nifty.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131300 Archived-At: Hello. I found this thread reported in 2012: https://lists.gnu.org/archive/html/bug-gnu-emacs/2012-07/msg00311.html It reported that Ctrl-G in an emacs running in a terminal sends a SIGINT to the parent shell. I tested it in newer Emacs version (Emacs 26.3), and found the behavior was opposite. So, something has changed since then. I'd like to know what was changed. The following is the detailed steps for my tests. I invoked 'emacs -nw' from bash running in a terminal. Let's say I am using the terminal, /dev/pts/28. I used 'stty' from another terminal in order to confirm 'intr' key was changed to ^G from ^C. $ stty -a -F /dev/pts/28 speed 38400 baud; rows 27; columns 224; line = 0; intr = ^G; quit = ^G; erase = ^?; kill = ^U; eof = ^D; eol = ; [ snip ] I used strace to check if SIGINT was delivered when I pressed Ctrl-G. I opened another terminal, and ran: $ sudo strace -e trace=signal -p I opened yet anther terminal, and ran: $ sudo strace -e trace=signal -p When I pressed Ctrl-G in the Emacs window, I saw SIGINT logs in the first terminal, which is tracing the emacs. In contrast, I saw nothing in the second one, which is tracing the parent shell. In my understanding, when a user provides keyboard-interrupt, all the foreground processes in that terminal will receive SIGINT. How can Emacs block SIGINT from being delivered to the parent shell? BTW, I noticed this when I was reading this article: https://www.cons.org/cracauer/sigint.html That article says: "If C-g is used in Emacs, both the shell and Emacs will have received SIGINT. Emacs will not exit, the user used C-g as a normal editing keystroke, he/she does not want the script to be aborted on C-g." It also contradicts to the current behavior of Emacs. I am curious how the current behavior was archieved. Thanks. -- Best Regards Masahiro Yamada