From unknown Sat Sep 20 15:54:00 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#73100 <73100@debbugs.gnu.org> To: bug#73100 <73100@debbugs.gnu.org> Subject: Status: Regarding a bug in suspend-emacs Reply-To: bug#73100 <73100@debbugs.gnu.org> Date: Sat, 20 Sep 2025 22:54:00 +0000 retitle 73100 Regarding a bug in suspend-emacs reassign 73100 emacs submitter 73100 Riza Dindir severity 73100 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 07 10:43:39 2024 Received: (at submit) by debbugs.gnu.org; 7 Sep 2024 14:43:39 +0000 Received: from localhost ([127.0.0.1]:57169 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smwf4-0000Sy-6u for submit@debbugs.gnu.org; Sat, 07 Sep 2024 10:43:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:40234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smuhS-0001Da-7l for submit@debbugs.gnu.org; Sat, 07 Sep 2024 08:37:58 -0400 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 1smuhR-0000u3-0V; Sat, 07 Sep 2024 08:37:57 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smuhP-0006uQ-B7; Sat, 07 Sep 2024 08:37:56 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-277df202ca9so1651152fac.0; Sat, 07 Sep 2024 05:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725712673; x=1726317473; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=zsMU3oMmja4U1QnCOJ2ZKoLD+1tTkcMvBWF7vYTMK3I=; b=aXQVTsuFlS6tLABqj58YBQZmq/rmpY+A0cL21SyGsyaEyPzme1qpTI8ymuOzSLIL5G yDvWvP34hRkyRJLulHzPdji7QHbpZ4lY+0+KabiN7R4SubBCyRwW2pz+0Jqy2A+B4BBe x/pCB0l+RR/VAqC3lgJrMg8YGJDH4IowSewfxGdb8ItGHRjaxZGBM20fUIIdVhsqf4/X u10yjHIM55FsziHAvRyfXUdIJ7Yhzq3bp1EUbcVTI3pUAKqgNtCcjj7xkmSxCVkR5SoW p5ZsvAKhn+yG2Jw99MhZ5OoBjw6YqFVvfwcrNhF9y1qE9JBDE2ztgy9PFs7v5CNS3Fb+ dD9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725712673; x=1726317473; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zsMU3oMmja4U1QnCOJ2ZKoLD+1tTkcMvBWF7vYTMK3I=; b=ZZHiXnLYTfUW+q7ekAysqDlKC6Tll3WmjD3bOxJaQR66d7pAHldZileJntyU98n121 eYGPlspJPoFQqm03piHtLSlXJZkSHJwP3zWjYgTBWqDgcTVILsUWMzZ8AjmNTrJ8piIU D+PA88NgDbsoqn1IJnMQYC/7asmU5XUrrzw9zwd/iU3Z9b7+KciVgFLnJZWVZ7+txcnv tAn/c0ghblbtEbWYg2oTAG38AE4UuZDOd0zKJbIvxlM2iGRQf9e3tLF/C0+Qjj5iQwEo t5oh3sB4tu8ThLsKSzuz6G46ggh8FSkzJPdy14ByXdQ0cdGKvcGPuKhsLAE64s6WR+2t PdQA== X-Forwarded-Encrypted: i=1; AJvYcCWU2ZR/1n30kxi87gRqRIinSTt6qIq1OxgJ4prbWUs2EcIUZ6STxPrjlrSYdyQrvF5OuyQIsNcMZMPoqesCMw==@gnu.org X-Gm-Message-State: AOJu0YyL0I1jL1LXLiPIZwmjHK7ieE1YRyv3LARi34YtH3e2TnyOnruJ eZTKDNqRpe3xNrz1Fca3cv7LviTDqvc3XLV8rH23+W2jmeVOzJ0gOHmjFDbHBE6isL8wYKf0i1N ALWPHOX82GMWsR5aN4eW5SCvQqS5TxNeN0h0= X-Google-Smtp-Source: AGHT+IHqHWxP7eeu0V1ul7xjCxXM5boSgZjMst0w9SngemP0ZlIUm9GaDZJfBmhs0vif5MWPyXeuxQU1XTy0F+fg55Q= X-Received: by 2002:a05:6870:3646:b0:27b:55af:ca2b with SMTP id 586e51a60fabf-27b9d7f81c9mr971325fac.11.1725712673453; Sat, 07 Sep 2024 05:37:53 -0700 (PDT) MIME-Version: 1.0 From: Riza Dindir Date: Sat, 7 Sep 2024 15:37:17 +0300 Message-ID: Subject: Regarding a bug in suspend-emacs To: bug-gnu-emacs@gnu.org, help-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="000000000000e2beaf062186ca62" Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=riza.dindir@gmail.com; helo=mail-oa1-x2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 07 Sep 2024 10:43:33 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000e2beaf062186ca62 Content-Type: text/plain; charset="UTF-8" Hello I am running Linux with kernel 6.6.47 and am running emacs in xterm, using the -nw command line argument. I am new to emacs and was experimenting with the suspend-emacs command. Following the example on https://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html . When following the example, I added the suspend-resume-hook to my .emacs.d/init.el file. When I run M-: (suspend-emacs "pwd") it does not show the current working directory. But when I do fg from the terminal that I got into, I see the "Resumed!" message. I asked in the libera chat about that, and also in the gnu-help-emacs list. I have been talking to wasamasa on libera chat (#emacs-beginners) and we pinpointed the problem to the stuff_char function (in https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). We came to this point from stuff_buffered_input ( https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11963), and from suspend-emacs function definition (in https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11908). The stuff_char function is using ioctl with TIOCSTI. TIOCSTI requires CAP_SYS_ADMIN capability. You can set this capability using sysctl setting dev.tty.legacy_tiocsti to 1. Unless I had set "dev.tty.legacy_tiocsti" to 1 I could not run the suspend-emacs command with an argument string. Either emacs can check the return value of ioctl in stuff_char and if there return value is EPERM, then handle this accordingly, with a message regarding the problem. Or the information relating to the kernel version and CAP_SYS_ADMIN can be added to the infor page os suspend_emacs, along with the information on how to set this capability using sysctl. Kind Regards Riza Dindir --000000000000e2beaf062186ca62 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello

I am running Linux wit= h kernel 6.6.47 and am running emacs in xterm, using the -nw command line a= rgument.

I am new to emacs and was experimenti= ng with the suspend-emacs command. Following the example on https://www.gnu.org/software/emacs/manual/html_node/eli= sp/Suspending-Emacs.html.

When following the e= xample, I added the suspend-resume-hook to my .emacs.d/init.el file. When I= run M-: (suspend-emacs "pwd") it does not show the current working directory. But when I do fg from= the terminal that I got into, I see the "Resumed!" message.

I asked in the libera chat about that, and also in the= gnu-help-emacs list. I have been talking to wasamasa on libera chat (#emac= s-beginners) and we pinpointed the problem to the stuff_char function (in <= a href=3D"https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n40= 3" target=3D"_blank">https://git.savannah.gnu.org/cgit/emacs.git/tree/src/s= ysdep.c#n403). We came to this point from stuff_buffered_input (https://git.savannah.gnu.org/cgit/emacs.git/tree/src/key= board.c#n11963), and from=C2=A0 suspend-emacs function definition (in <= a href=3D"https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n= 11908" target=3D"_blank">https://git.savannah.gnu.org/cgit/emacs.git/tree/s= rc/keyboard.c#n11908).

The stuff_char function= is using ioctl with TI= OCSTI. TIOCSTI requires CAP_SYS_ADMIN capability. You can set this capabili= ty using sysctl setting dev.tty.legacy_tiocsti to 1.

Unless I had set "dev.tty.legacy_tiocsti" to 1 I could not ru= n the suspend-emacs command with an argument string.

Either emacs can check the return value of ioctl in stuff_char and if th= ere return value is EPERM, then handle this accordingly, with a message reg= arding the problem.

Or the information relating to= the kernel version and CAP_SYS_ADMIN can be added to the infor page os sus= pend_emacs, along with the information on how to set this capability using = sysctl.

Kind Regards
Riza Dindir
--000000000000e2beaf062186ca62-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 07 11:21:07 2024 Received: (at 73100) by debbugs.gnu.org; 7 Sep 2024 15:21:08 +0000 Received: from localhost ([127.0.0.1]:57224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smxFL-0002aS-Hy for submit@debbugs.gnu.org; Sat, 07 Sep 2024 11:21:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smxFH-0002ZZ-26 for 73100@debbugs.gnu.org; Sat, 07 Sep 2024 11:21:05 -0400 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 1smxFA-0007cx-HC; Sat, 07 Sep 2024 11:20:56 -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=FcjixUUuVQ0a91fX2NvdQVFR8sqtIVmfWmHb+Nj4ifI=; b=ElWOv6wdQ3gv mj3MyI349B4aD286OCfUs7x90QTacRi4hQeykcEUygTG5qZv3kglK5/3DqqRl4xR4jA7s0dGXywbx R1k4CLjToDeQ0t9iPBHQ0NxuCrw9y5ZpFpa5UvOg3gufewU0UZLLFRyxIQlnrjSl5VrZ1pitKuNfP RW3p9qMUDJWKR2vk8GI5ypGKojmMqw9DsgpffmHCBG8vbQEI89pHiS8zIACTeN0wqLZVeEJ/ok3TS WoJo3KO+uIOTgAxR7WR8oYCqBb+vZ79V3TXmZfw/vBYt8QMmzIjUeIdEeFGNqyeKTxkxeiDUgYW9b aCXG7/UrVLBxlow3NY9xTg==; Date: Sat, 07 Sep 2024 18:20:54 +0300 Message-Id: <867cbnxzft.fsf@gnu.org> From: Eli Zaretskii To: Riza Dindir In-Reply-To: (message from Riza Dindir on Sat, 7 Sep 2024 15:37:17 +0300) Subject: Re: bug#73100: Regarding a bug in suspend-emacs References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73100 Cc: 73100@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Riza Dindir > Date: Sat, 7 Sep 2024 15:37:17 +0300 > > I am running Linux with kernel 6.6.47 and am running emacs in xterm, using the -nw command line argument. > > I am new to emacs and was experimenting with the suspend-emacs command. Following the example on > https://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html. > > When following the example, I added the suspend-resume-hook to my .emacs.d/init.el file. When I run M-: > (suspend-emacs "pwd") it does not show the current working directory. But when I do fg from the terminal that I > got into, I see the "Resumed!" message. > > I asked in the libera chat about that, and also in the gnu-help-emacs list. I have been talking to wasamasa on > libera chat (#emacs-beginners) and we pinpointed the problem to the stuff_char function (in > https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). We came to this point from > stuff_buffered_input (https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11963), and from > suspend-emacs function definition (in https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11908). > > The stuff_char function is using ioctl with TIOCSTI. TIOCSTI requires CAP_SYS_ADMIN capability. You can set > this capability using sysctl setting dev.tty.legacy_tiocsti to 1. > > Unless I had set "dev.tty.legacy_tiocsti" to 1 I could not run the suspend-emacs command with an argument > string. > > Either emacs can check the return value of ioctl in stuff_char and if there return value is EPERM, then handle > this accordingly, with a message regarding the problem. You mean, you want suspend-emacs signal an error if it is called with STUFFSTRING argument, but fails to stuff the string into the terminal's input buffer? From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 07 11:23:01 2024 Received: (at control) by debbugs.gnu.org; 7 Sep 2024 15:23:01 +0000 Received: from localhost ([127.0.0.1]:57231 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smxHA-0002eb-HR for submit@debbugs.gnu.org; Sat, 07 Sep 2024 11:23:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smxH8-0002eG-7y; Sat, 07 Sep 2024 11:22:58 -0400 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 1smxH2-0007ie-0w; Sat, 07 Sep 2024 11:22:52 -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=2OxxWmRtwi4ZIbum5EA8fSVbXgqLDg0gJWH+vSAlWRg=; b=jowIaoGgeY6c 9bXiDyhaq5p6Prkf3TcUU8IokCm2R+UVWXRmzhnt2AzwJ0uis4O58Zs41X/PKA1Liey0pg34BspH0 X2ZX4yhgAAIcSH2reTVw0zXwj8BOpidwsXJWplfgd3acSUtA65svkjen5C0//Safe7Ph569bRr5bF aEIT13rTk0MvxL4xhBOlEgHOpR/hUqzltEjE4TO3wMM7eJkUwIF9/yPDb4JhlOC2U8pbKsdmcMb5r cW9TP4XrMO6TNQC0FZB/JRVUQdSIc/DyIsOKKUHU21s08iO7XjCr8zZbplku10esXTVXx32271rCe M2jF/YsNKhU4D7rHv/OJlA==; Date: Sat, 07 Sep 2024 18:22:07 +0300 Message-Id: <865xr7xzds.fsf@gnu.org> From: Eli Zaretskii To: Riza Dindir In-Reply-To: (message from Riza Dindir on Sat, 7 Sep 2024 16:34:45 +0300) Subject: Re: bug#73101: Regarding a bug in suspend-emacs References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control Cc: 73101@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) merge 73101 73100 thanks > From: Riza Dindir > Date: Sat, 7 Sep 2024 16:34:45 +0300 > > Note: Sending this a second time, I forgot to confirm my request to register to the bug-gnu-emacs list. That was a mistake, because by doing that you have created an identical copy of the first bug report. I'm now merging them. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 07 12:30:07 2024 Received: (at 73100) by debbugs.gnu.org; 7 Sep 2024 16:30:07 +0000 Received: from localhost ([127.0.0.1]:57330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smyK6-0006JZ-MO for submit@debbugs.gnu.org; Sat, 07 Sep 2024 12:30:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smyK3-0006GX-P6 for 73100@debbugs.gnu.org; Sat, 07 Sep 2024 12:30:05 -0400 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 1smyJx-00064a-Cu; Sat, 07 Sep 2024 12:29:57 -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=J0aCf6NC+9Q3Ao6LlqnjU0CcuP1HQJsK5uzk99Ap/no=; b=PQTNhq08BYJu TzgaauEGOHXgFhLtusiIwhsNCtDFvGtB4o2b/G1ddpfiozF9Nv1MWKwnvoe4A63y3ypPxjfDQfXOZ RsloFyWQm22739VWRwWtgqMTRqToCvbMOC5LVuEWeukObQlEgwOKYRrvGr+s4IfWJi6FgGflu2HA1 H2hNQ8R4c3W9RtZzWdHRDHYrRxVHZRHgv4fvwGXyf89pnz2wF8Gu8tDEFMElxDNayzOeZchS8IG1w HHutFQaimuZrN33e/NjEcaZpufYsmtEX0UIRA2QRtzCAc1fUVeu1SR2pS1Ycb/74W197j7u+FPZRm WA9WYUosTvUIvsDBrtYHow==; Date: Sat, 07 Sep 2024 19:29:53 +0300 Message-Id: <8634mbxw8u.fsf@gnu.org> From: Eli Zaretskii To: Riza Dindir In-Reply-To: (message from Riza Dindir on Sat, 7 Sep 2024 19:11:02 +0300) Subject: Re: bug#73100: Regarding a bug in suspend-emacs References: <867cbnxzft.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73100 Cc: 73100@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Riza Dindir > Date: Sat, 7 Sep 2024 19:11:02 +0300 > Cc: 73100@debbugs.gnu.org > > I am new to the code base, and it was just a suggestion to check for the ioctl call for any failures and take > precautions, maybe inform the user of the issue that the suspend-emacs command did not run correctly. Since > the command was not printing out anything when called with 'M-: (suspend-emacs "pwd")' I was not sure what > was happening. I was asking for your user's expectations, not how to do that in the code. > For users that use the linux kernel 6.2+ the ioctl command does not work correctly. When the STUFFSTRING is > passed to the suspend-emacs command, it does nothing. The problem with kernel 6.2+ is that it requires > CAP_SYS_ADMIN capability (https://www.man7.org/linux/man-pages/man2/TIOCSTI.2const.html). > > In the code at some point suspend-emacs command calls stuff_char, which uses ioctl (code snippet below, from > https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). The ioctl call fails. But in the code there is > no check for that, that might confuse people that use linux kernel 6.2+. I wanted to use suspend-emacs with > "pwd" as the string (as shown in the example in the documentation in > https://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html). But the "pwd" command > was not displaying anything. Because it was not being sent/stuffed to the superior process. Does ioctl return -1 in that case? (I don't have access to a system where it fails, it works for me on GNU/Linux.) > Adding an error check would be one of the solutions. Assuming we can check that (see above), the question is what to do if we do detect a failure. > The other solution might be to add a piece of information to the documentation for suspend-emacs, (and > maybe to the documentation string for suspend-emacs) regarding this problem. So that people that use linux > kernel 6.2+ would be aware of this issue. That is already done, except that the documentation cannot be too specific regarding when and under what conditions it could happen. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 07 14:21:59 2024 Received: (at 73100) by debbugs.gnu.org; 7 Sep 2024 18:22:00 +0000 Received: from localhost ([127.0.0.1]:57598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sn04N-0004Fh-0X for submit@debbugs.gnu.org; Sat, 07 Sep 2024 14:21:59 -0400 Received: from mail-oa1-f54.google.com ([209.85.160.54]:61854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smy3J-0005On-Ju for 73100@debbugs.gnu.org; Sat, 07 Sep 2024 12:12:46 -0400 Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-277cfd3f07aso1410520fac.3 for <73100@debbugs.gnu.org>; Sat, 07 Sep 2024 09:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725725499; x=1726330299; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wkpdHm1DhdR+OUZwSFSsdGHrKf60/yX1bq84mvyfP8Q=; b=ayxadLPpkqNP8vGNfQjZ57FwDSKVrp92QkAZ1DAMdcraYUn9jdghOOO1RznKu/L7N2 8hNNm4nSmgM1H44rY3NNZOwh1Vn/DilY56jAwr5Kl06sOQojV5PVpMVZQDiPfFblWx/+ seljn2333BVQyg9eUbmvi8u1v8R2fkWwOvs/UElue45JDWrRcNQzIQTRMBnm5zGmVI/3 Gy5oNZsKx5AoI3YZof9neE7Q4pxMKbOC5e6wadztUqHZibg6hZX2+fZ19Mz/5v2XjxPL YI26VHWkCXq2Cp1XaEbR0CFC5Zv1Y4aakIdW7fbXolUTdSnaOlDumuraC1/+nEHYXb/U lmIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725725499; x=1726330299; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wkpdHm1DhdR+OUZwSFSsdGHrKf60/yX1bq84mvyfP8Q=; b=Hyf6aG7FlIzoTAzwSE8C18l2Tuc2VV/M1D94MZASqlr2WwvfCY36k22+xgRTgjvP2A 9lLmjtfXlXamZtwMnsKocaAsc5N8kPPMmcZGH+9GPuqdf1muKWj4CnD8XeFNLqmCLyJG UuEcwVP9OJN4Nsu5pJD3LTbgN2Nsj0hMfadHNJdsVMer8vxyVEgiQUjdc8zx/HZdLliu E5REp+J31tiSe/kf8MUV+UqCl6ysAl3xN/TaSunvYprRg2TN5fmVFt0vGTuE3yBVla92 yx9sZIN2oKGrUMToPOtQQos8MgCxEXQp/a6epJm+LZS/yFt/gSMgbFhpJWP0zgofOO9A fbdQ== X-Gm-Message-State: AOJu0Yz6YssTCkuR6w6mANR0mk/7P2DTTeTDlG2dbekqi2iEJ54vThrm ZIk0gT6lHA3aqJjW9DdNQjPprOhYaVoECBJxji+eTulLLVFWZet+dfOHaG6Nlj+AVDdDeJm5Si7 5hqGM6+VvG0yK8FfOD7uXwMZYVXp8Y+2sCa0= X-Google-Smtp-Source: AGHT+IHHTC+vNV+pj2mTiRjyUS6WeBdrgzrcxTMhycvjRy2J8AHC4Tt1PqZ5oJ/Cr6hTX5zT3Q2KtXYhl4gbWY7u2+4= X-Received: by 2002:a05:6870:c1cb:b0:278:252d:9ac9 with SMTP id 586e51a60fabf-27b9dc9fb8dmr1075573fac.45.1725725498967; Sat, 07 Sep 2024 09:11:38 -0700 (PDT) MIME-Version: 1.0 References: <867cbnxzft.fsf@gnu.org> In-Reply-To: <867cbnxzft.fsf@gnu.org> From: Riza Dindir Date: Sat, 7 Sep 2024 19:11:02 +0300 Message-ID: Subject: Re: bug#73100: Regarding a bug in suspend-emacs To: Eli Zaretskii Content-Type: multipart/alternative; boundary="00000000000058905e062189c71f" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 73100 X-Mailman-Approved-At: Sat, 07 Sep 2024 14:21:52 -0400 Cc: 73100@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --00000000000058905e062189c71f Content-Type: text/plain; charset="UTF-8" Hello Eli, I am new to the code base, and it was just a suggestion to check for the ioctl call for any failures and take precautions, maybe inform the user of the issue that the suspend-emacs command did not run correctly. Since the command was not printing out anything when called with 'M-: (suspend-emacs "pwd")' I was not sure what was happening. For users that use the linux kernel 6.2+ the ioctl command does not work correctly. When the STUFFSTRING is passed to the suspend-emacs command, it does nothing. The problem with kernel 6.2+ is that it requires CAP_SYS_ADMIN capability (https://www.man7.org/linux/man-pages/man2/TIOCSTI.2const.html). In the code at some point suspend-emacs command calls stuff_char, which uses ioctl (code snippet below, from https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). The ioctl call fails. But in the code there is no check for that, that might confuse people that use linux kernel 6.2+. I wanted to use suspend-emacs with "pwd" as the string (as shown in the example in the documentation in https://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html). But the "pwd" command was not displaying anything. Because it was not being sent/stuffed to the superior process. /* Should perhaps error if in batch mode */#ifdef TIOCSTI ioctl (fileno (CURTTY()->input), TIOCSTI, &c);#else /* no TIOCSTI */ error ("Cannot stuff terminal input characters in this version of Unix");#endif /* no TIOCSTI */ I have downloaded the code for emacs 29.4 and compiled it with a simple error check and the ioctl call failed on my system silently (with kernel 6.6.47). To add a check is of course for the people who develop emacs to decide. I have seen the code today, and am not in a position to suggest anything at this stage. Maybe there would be a better way of handling this error. Adding an error check would be one of the solutions. The other solution might be to add a piece of information to the documentation for suspend-emacs, (and maybe to the documentation string for suspend-emacs) regarding this problem. So that people that use linux kernel 6.2+ would be aware of this issue. The issue is fixable by just setting the dev.tty.legacy_tiocsti sysctl variable to 1. This variable was set to 0 on my system. Hence the ioctl call for TIOCSTI was failing, and no indication of the error was given. After I have read the man page for TIOCSTI, and set the sysctl variable dev.tty.legacy_tiocsti to 1 was I able to call suspend-emacs with a STUFFSTRING and it worked. It was displaying the output of the "pwd" command. Regards Riza On Sat, Sep 7, 2024, 18:20 Eli Zaretskii wrote: > > From: Riza Dindir > > Date: Sat, 7 Sep 2024 15:37:17 +0300 > > > > I am running Linux with kernel 6.6.47 and am running emacs in xterm, > using the -nw command line argument. > > > > I am new to emacs and was experimenting with the suspend-emacs command. > Following the example on > > > https://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html > . > > > > When following the example, I added the suspend-resume-hook to my > .emacs.d/init.el file. When I run M-: > > (suspend-emacs "pwd") it does not show the current working directory. > But when I do fg from the terminal that I > > got into, I see the "Resumed!" message. > > > > I asked in the libera chat about that, and also in the gnu-help-emacs > list. I have been talking to wasamasa on > > libera chat (#emacs-beginners) and we pinpointed the problem to the > stuff_char function (in > > https://git.savannah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). We > came to this point from > > stuff_buffered_input ( > https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11963), > and from > > suspend-emacs function definition (in > https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11908). > > > > The stuff_char function is using ioctl with TIOCSTI. TIOCSTI requires > CAP_SYS_ADMIN capability. You can set > > this capability using sysctl setting dev.tty.legacy_tiocsti to 1. > > > > Unless I had set "dev.tty.legacy_tiocsti" to 1 I could not run the > suspend-emacs command with an argument > > string. > > > > Either emacs can check the return value of ioctl in stuff_char and if > there return value is EPERM, then handle > > this accordingly, with a message regarding the problem. > > You mean, you want suspend-emacs signal an error if it is called with > STUFFSTRING argument, but fails to stuff the string into the > terminal's input buffer? > --00000000000058905e062189c71f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello Eli,

=
I am new to the code base, and it was just a suggestion to check for t= he ioctl call for any failures and take precautions, maybe inform the user = of the issue that the suspend-emacs command did not run correctly. Since th= e command was not printing out anything when called with 'M-: (suspend-= emacs "pwd")' I was not sure what was happening.

For users that use the linux kernel 6.2+ the ioctl command= does not work correctly. When the STUFFSTRING is passed to the suspend-ema= cs command, it does nothing. The problem with kernel 6.2+ is that it requir= es CAP_SYS_ADMIN capability (https://www.man= 7.org/linux/man-pages/man2/TIOCSTI.2const.html).

In the code at some point suspend-emacs command calls stuff_char, which = uses ioctl (code snippet below, from https://git.savannah.gnu.org/cgit/= emacs.git/tree/src/sysdep.c#n403). The ioctl call fails. But in the cod= e there is no check for that, that might confuse people that use linux kern= el 6.2+. I wanted to use suspend-emacs with "pwd" as the string (= as shown in the example in the documentation in https://ww= w.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html).= But the "pwd" command was not displaying anything. Because it wa= s not being sent/stuffed to the superior process.

/* Should perhaps er=
ror if in batch mode */
#ifdef TIOCSTI
  ioctl (fileno (CURTT=
Y()->input), TIOCSTI, &c);
#else /* no TIOCSTI */
  error ("Cannot stuff ter=
minal input characters in this version of Unix");
#endif /* no TIOCSTI */

I have downloaded the code for emacs 29.4 and compiled it with a = simple error check and the ioctl call failed on my system silently (with ke= rnel 6.6.47).

To add a check is o= f course for the people who develop emacs to decide. I have seen the code t= oday, and am not in a position to suggest anything at this stage. Maybe the= re would be a better way of handling this error.

A= dding an error check would be one of the solutions.

The other solution might be to add a piece of information to the docu= mentation for suspend-emacs, (and maybe to the documentation string for sus= pend-emacs) regarding this problem. So that people that use linux kernel 6.= 2+ would be aware of this issue.

The issue is fixa= ble by just setting the dev.tty.legacy_tiocsti sysctl variable to 1. This v= ariable was set to 0 on my system. Hence the ioctl call for TIOCSTI was fai= ling, and no indication of the error was given. After I have read the man p= age for TIOCSTI, and set the sysctl variable=C2=A0dev.tty.legacy_tiocsti to= 1 was I able to call suspend-emacs with a STUFFSTRING and it worked. It wa= s displaying the output of the "pwd" command.

<= /div>
Regards
Riza


On Sa= t, Sep 7, 2024, 18:20 Eli Zaretskii <eliz@gnu.org> wrote:
> From: Riza Dindir <riza.dindir@gmail.= com>
> Date: Sat, 7 Sep 2024 15:37:17 +0300
>
> I am running Linux with kernel 6.6.47 and am running emacs in xterm, u= sing the -nw command line argument.
>
> I am new to emacs and was experimenting with the suspend-emacs command= . Following the example on
> https= ://www.gnu.org/software/emacs/manual/html_node/elisp/Suspending-Emacs.html<= /a>.
>
> When following the example, I added the suspend-resume-hook to my .ema= cs.d/init.el file. When I run M-:
> (suspend-emacs "pwd") it does not show the current working d= irectory. But when I do fg from the terminal that I
> got into, I see the "Resumed!" message.
>
> I asked in the libera chat about that, and also in the gnu-help-emacs = list. I have been talking to wasamasa on
> libera chat (#emacs-beginners) and we pinpointed the problem to the st= uff_char function (in
>
https://git.savann= ah.gnu.org/cgit/emacs.git/tree/src/sysdep.c#n403). We came to this poin= t from
> stuff_buffered_input (https://git.savannah.gnu.org/cgit/emacs.git/tree/src/keyboard.c#n11= 963), and from
> suspend-emacs function definition (in https://git.savannah.gnu.org/cgit/emacs.git/tree/sr= c/keyboard.c#n11908).
>
> The stuff_char function is using ioctl with TIOCSTI. TIOCSTI requires = CAP_SYS_ADMIN capability. You can set
> this capability using sysctl setting dev.tty.legacy_tiocsti to 1.
>
> Unless I had set "dev.tty.legacy_tiocsti" to 1 I could not r= un the suspend-emacs command with an argument
> string.
>
> Either emacs can check the return value of ioctl in stuff_char and if = there return value is EPERM, then handle
> this accordingly, with a message regarding the problem.

You mean, you want suspend-emacs signal an error if it is called with
STUFFSTRING argument, but fails to stuff the string into the
terminal's input buffer?
--00000000000058905e062189c71f--