From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#72117: Command doesn't execute correctly in eshell Date: Fri, 26 Jul 2024 22:18:22 -0700 Message-ID: <51486b9f-cc61-62af-8529-8850fb98f051@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2W3BnSGYVPgCF1EXHcaBNzML" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36029"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eliz@gnu.org To: the_wurfkreuz , 72117@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 27 07:20:29 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 1sXZr2-0009Hl-Tc for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Jul 2024 07:20:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXZqV-0004zX-LO; Sat, 27 Jul 2024 01:19:55 -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 1sXZqT-0004zH-Eg for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 01:19:53 -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 1sXZqT-0001nW-73 for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 01:19:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sXZqc-0004c1-ER for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 01:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jul 2024 05:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72117 X-GNU-PR-Package: emacs Original-Received: via spool by 72117-submit@debbugs.gnu.org id=B72117.172205758117690 (code B ref 72117); Sat, 27 Jul 2024 05:20:02 +0000 Original-Received: (at 72117) by debbugs.gnu.org; 27 Jul 2024 05:19:41 +0000 Original-Received: from localhost ([127.0.0.1]:40351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXZqH-0004bG-49 for submit@debbugs.gnu.org; Sat, 27 Jul 2024 01:19:41 -0400 Original-Received: from mail-oa1-f41.google.com ([209.85.160.41]:61443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXZqE-0004az-Lz for 72117@debbugs.gnu.org; Sat, 27 Jul 2024 01:19:39 -0400 Original-Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-25d634c5907so1206341fac.2 for <72117@debbugs.gnu.org>; Fri, 26 Jul 2024 22:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722057503; x=1722662303; darn=debbugs.gnu.org; h=in-reply-to:cc:references:to:from:content-language:subject :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=ia93J/fPuH41TR96a2DdvFJOBUYUzbE/KWlGfgItlEk=; b=b+HtQINLUc09VbPU73VI2Vu+klywxIxONdK553VhegDGxR6WRs3welSU+vGqwqdbDs DLjA9y9k7TNZ08iWfvSUxceUQXaa1RKXLaDwn5zdAZ7rV/OFH+oObj9X5t+arkdEStku T8gb7ZnqrUYqJtQsESdL+u6AjIqwnYb722lH9nbL68tCGeUEadKvAfRzBAR5ttBWX2zK WGCw+vgwJG/LMd4OikuOnK83K8iFoFcAAZzNMKWb+PGdi/ETlBX9n+u47bQ7Vqjl6g1X 8LXcP//fz+9X+1fBy6J+5uCFRkhmtkxb8VuTyVjNYO2e32x9EHrPcvUyNaV4XGD8VLaO qoUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722057503; x=1722662303; h=in-reply-to:cc:references:to:from:content-language:subject :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=ia93J/fPuH41TR96a2DdvFJOBUYUzbE/KWlGfgItlEk=; b=L7Pe2VmVO3+FJXesAH+yo3gD635gxfQpfRgeS0nzFkgRcnQxkYnwmmRIoZ/OLAXkaM pLBafcmII2JIAImlvBuEsR0zM7hr7INc6K2ck7PzN10+38rUjGGik5DqeFkXLy7KNUAw Ewm6V9MPDQ/Rk0noK59zyuDGHnmUczvr8k9WGnPO1pHA9pEsS2b5UbBhp37jaPJf5TlV b94rgrx0Foi6CiPCA6SUD5ii3/0CJuuDK2yd7uC0hegS7WTyXmaC7tryEJBOnCyWfLk+ ZvJsQ0KSjLLD6JS3qpaE1im70FJ8+k3dlK5uPNJqRccvwRTyq+wsYuXov954itL+Ns5s bJYQ== X-Forwarded-Encrypted: i=1; AJvYcCW+Y3cUU1d7pn3P7y9XaiaOJfgmw9EzcmDcCybXcrVZX8OvD29gqAsoABm0MtzQG43jwPSRfBsf3kX6uO2loScEYaciLx4= X-Gm-Message-State: AOJu0YyIPB9iC5u8OKfTQYILe0/nepYXYWtFMmV51Razo1pICH8Syt4D DmTLnBX1iHybt27EcV1LHEGWktJi+F3BuX2I2x6yTCm/jUntD9xT X-Google-Smtp-Source: AGHT+IG1XeAXZ6exHBvppCLC8tn2gdl/KLZ3ZANNTCwDvy8vayV9Vkas0eL9SwKDu7MQmvngZzoHqQ== X-Received: by 2002:a05:6871:b22:b0:261:360:746c with SMTP id 586e51a60fabf-267d4d37e6dmr2467169fac.19.1722057503254; Fri, 26 Jul 2024 22:18:23 -0700 (PDT) Original-Received: from [192.168.1.2] (syn-023-240-098-037.res.spectrum.com. [23.240.98.37]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-70ead812300sm3510583b3a.114.2024.07.26.22.18.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jul 2024 22:18:22 -0700 (PDT) Content-Language: en-US In-Reply-To: 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:289400 Archived-At: This is a multi-part message in MIME format. --------------2W3BnSGYVPgCF1EXHcaBNzML Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 7/14/2024 6:01 PM, Jim Porter wrote: > On 7/14/2024 12:33 PM, the_wurfkreuz via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >  But that's not the most interesting part. I can execute the >> command with 'eshell/sudo'. But after the command execution emacs will >> take the whole CPU processing time if i have >> '(global-display-line-numbers-mode 1)' >> option enabled. > > I can't reproduce this particular issue, but I can reproduce *an* issue. > It seems to be due to "head -10" exiting early (as it should), which > results in a broken pipe. However, Eshell's broken pipe handling wasn't > properly cleaning up the process ("grep" in this example). Eli, would this patch (re-attached here) be ok for Emacs 30? It's not a perfect solution (the fix currently on master is much better), but it's the least-risky change to this code that I could make, and it should improve matters somewhat for the release branch. To summarize the problem so you have a bit more context for what this is changing: in Eshell, if you have a pipeline like "cat some-file | head -10", then the "head" process can exit early and raise an 'eshell-pipe-broken' signal. The process filter for "cat" will catch this signal and try to send SIGPIPE to the actual "cat" process. However, for MS-Windows (which doesn't have SIGPIPE), and Tramp (where I couldn't get 'signal-process' to work due to another bug[1]), it just deletes the process. Unfortunately, that was failing to clean up the stderr "process" object, which caused Eshell to think the command wasn't complete. By changing to 'kill-process', this cleanup happens and things work more smoothly. If you'd prefer to leave it as-is on Emacs 30, I don't mind either. This bug has been present since 29.1, and it took quite a while for anyone to notice it, so it probably doesn't come up terribly often. [1] This is now fixed. --------------2W3BnSGYVPgCF1EXHcaBNzML Content-Type: text/plain; charset=UTF-8; name="0001-Use-kill-process-as-a-fallback-when-a-pipe-gets-brok.patch" Content-Disposition: attachment; filename*0="0001-Use-kill-process-as-a-fallback-when-a-pipe-gets-brok.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSBjYzE4OGM1NmUwYjQzMTNlNTVhZjYwNjgzZjJkMWNmOWM3ZjAwZTFiIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBKaW0gUG9ydGVyIDxqcG9ydGVyYnVnc0BnbWFpbC5j b20+CkRhdGU6IFN1biwgMTQgSnVsIDIwMjQgMTY6NTE6NDMgLTA3MDAKU3ViamVjdDogW1BB VENIXSBVc2UgJ2tpbGwtcHJvY2VzcycgYXMgYSBmYWxsYmFjayB3aGVuIGEgcGlwZSBnZXRz IGJyb2tlbiBpbgogRXNoZWxsCgpUaGlzIGlzIGJldHRlciB0aGFuICdkZWxldGUtcHJvY2Vz cycgc2luY2UgaXQgd2lsbCBlbnN1cmUgdGhhdCBhbnkKc3RkZXJyIHBpcGUtcHJvY2Vzc2Vz IGdldCBzdG9wcGVkIGFzIHdlbGwgKGJ1ZyM3MjExNykuCgoqIGxpc3AvZXNoZWxsL2VzaC1w cm9jLmVsIChlc2hlbGwtaW5zZXJ0aW9uLWZpbHRlcik6IFVzZSAna2l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gICAg ICAgOzsgcHJvY2Vzcy4gIEZvciB1c2UgY2FzZXMgd2hlcmUgU0lHUElQRSBpcyB0cnVseQpA QCAtNTI5LDcgKzUyOSw3IEBAIGVzaGVsbC1pbnNlcnRpb24tZmlsdGVyCiAgICAgICAgICAg ICAgICAgICAoZXNoZWxsLXBpcGUtYnJva2VuCiAgICAgICAgICAgICAgICAgICAgKGlmIChv ciAocHJvY2Vzcy1nZXQgcHJvYyAncmVtb3RlLXBpZCkKICAgICAgICAgICAgICAgICAgICAg ICAgICAgIChlcSBzeXN0ZW0tdHlwZSAnd2luZG93cy1udCkpCi0gICAgICAgICAgICAgICAg ICAgICAgIChkZWxldGUtcHJvY2VzcyBwcm9jKQorICAgICAgICAgICAgICAgICAgICAgICAo a2lsbC1wcm9jZXNzIHByb2MpCiAgICAgICAgICAgICAgICAgICAgICAoc2lnbmFsLXByb2Nl c3MgcHJvYyAnU0lHUElQRSkpKSkpKQogICAgICAgICAgICAgICAgIChwcm9jZXNzLXB1dCBw cm9jIDplc2hlbGwtYnVzeSBuaWwpKSkpKSkKIAotLSAKMi4yNS4xCgo= --------------2W3BnSGYVPgCF1EXHcaBNzML--