From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70519: 30.0.50; Device for Emacs terminal I/O Date: Sat, 04 May 2024 20:19:38 +0300 Message-ID: <868r0pfqad.fsf@gnu.org> References: <871q6xkvm9.fsf@gmail.com> <86zftk4pau.fsf@gnu.org> <865xvthnm8.fsf@gnu.org> <87msp5bmvf.fsf@gmail.com> <86edahft33.fsf@gnu.org> <72ad1e4f-39fb-4287-874d-f0ddecb08e41@cs.ucla.edu> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26836"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70519@debbugs.gnu.org, eller.helmut@gmail.com To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 04 19:20:57 2024 Return-path: Envelope-to: geb-bug-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 1s3J4C-0006gg-89 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 May 2024 19:20:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3J3z-0007wt-R7; Sat, 04 May 2024 13:20:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3J3w-0007vS-87 for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 13:20:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3J3v-0006xI-Df for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 13:20:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s3J4I-0006H5-Fe for bug-gnu-emacs@gnu.org; Sat, 04 May 2024 13:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 May 2024 17:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70519 X-GNU-PR-Package: emacs Original-Received: via spool by 70519-submit@debbugs.gnu.org id=B70519.171484322124081 (code B ref 70519); Sat, 04 May 2024 17:21:02 +0000 Original-Received: (at 70519) by debbugs.gnu.org; 4 May 2024 17:20:21 +0000 Original-Received: from localhost ([127.0.0.1]:54783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3J3c-0006GL-RX for submit@debbugs.gnu.org; Sat, 04 May 2024 13:20:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s3J3a-0006GA-W6 for 70519@debbugs.gnu.org; Sat, 04 May 2024 13:20:19 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3J37-0006UO-UP; Sat, 04 May 2024 13:19:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=/ASYcw2CGdZMEmrBnzLRVkKx/0ALq/29mQ3YbCI41MY=; b=QY8pI19Bmw/G VmDmPZG1fTMX0eF7oBfUKEY8b/YqUEIes3WNt0ACQMAVoLPqPKnlDhUIuh/EDrlawBIkTFDzE+M3X Z2+Dlvnv252zDGr7L6TSUCtPlDef2vOXt2RZbWskYTyA6Li+ao1BOX4hNmf/qDCZal50ojugMxOXs 09l8HYZHC+AbHvRHSVtFBMDapizeGTbq/D7FXI3JCuVeO3cslNBWh7+uppnoBZGl+mDRT/M7Ac4gC eBoEw5xF3cM6afKAljgFIPu0M/SR7Of1wJrAMhTcnAm4KbyXBLgJ1ZZsiZPYEhGs5bRX9ORERWTgC 2Bb0nSxjjhscdmvVwgPIow==; In-Reply-To: <72ad1e4f-39fb-4287-874d-f0ddecb08e41@cs.ucla.edu> (message from Paul Eggert on Sat, 4 May 2024 09:36:23 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:284446 Archived-At: > Date: Sat, 4 May 2024 09:36:23 -0700 > Cc: 70519@debbugs.gnu.org > From: Paul Eggert > > On 2024-05-04 09:19, Eli Zaretskii wrote: > > AFAIU, the --terminal option causes > > Emacs to close its original stdin, so Ctrl-C does not send SIGINT to > > Emacs. But I'm nowhere near being an expert on that. Paul, can you > > please comment on that? > > Closing stdin doesn't change a process's controlling terminal. On > GNU/Linux you need to use ioctl with TIOCSCTTY and there are a bunch of > other preconditions. See how emacs_spawn uses TIOCSCTTY: > > /* We ignore the return value > because faith@cs.unc.edu says that is necessary on Linux. */ > ioctl (std_in, TIOCSCTTY, 0); So you are saying that the handling of --terminal in emacs.c is incomplete, in that it doesn't call that ioctl on the new stdin? because according to these comments in term.c, we do want the new terminal to become our controlling terminal: /* Create a termcap display on the tty device with the given name and type. If NAME is NULL, then use the controlling tty, i.e., dev_tty. Otherwise NAME should be a path to the tty device file, e.g. "/dev/pts/7". [...] #ifndef DOS_NT if (!strcmp (name, dev_tty)) ctty = 1; #endif [...] /* Open the terminal device. */ /* If !ctty, don't recognize it as our controlling terminal, and don't make it the controlling tty if we don't have one now. Alas, O_IGNORE_CTTY is a GNU extension that seems to be only defined on Hurd. On other systems, we need to explicitly dissociate ourselves from the controlling tty when we want to open a frame on the same terminal. */ int flags = O_RDWR | O_NOCTTY | (ctty ? 0 : O_IGNORE_CTTY); int fd = emacs_open (name, flags, 0); tty->input = tty->output = ((fd < 0 || ! isatty (fd)) ? NULL : emacs_fdopen (fd, "w+")); [...] if (!O_IGNORE_CTTY && !ctty) dissociate_if_controlling_tty (fd); In any case, is the result Helmut reports after typing Ctrl-C expected, or does it mean we have a bug when using --terminal? > This comment (and ignoring ioctl's return value) was added by rms in > commit 084fd64ac9daee2a89d393f07ce87ec8df543330 dated 1993. I'm > skeptical that the comment is true now. You might try adding code to > check the return value and report any errors, though Emacs shouldn't > abort (as it did before that 1993 change) if the ioctl fails. But emacs_spawn is about starting a sub-process, which is something different from what I'm talking about. Here, the issue is the Emacs's own terminal. Thanks.