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#54062: 29.0.50; [PATCH] Eshell should inform processes when a pipe is broken Date: Sat, 19 Feb 2022 22:19:26 +0200 Message-ID: <83ley6y5gx.fsf@gnu.org> References: <7da3e8b2-7400-dca6-6d92-0a60e3d9c215@gmail.com> <83mtinz222.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20016"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 54062@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 19 21:20:16 2022 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 1nLWDG-00052N-2f for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Feb 2022 21:20:14 +0100 Original-Received: from localhost ([::1]:44408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLWDE-0002Y6-N8 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Feb 2022 15:20:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLWD4-0002Xa-RG for bug-gnu-emacs@gnu.org; Sat, 19 Feb 2022 15:20:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLWD4-00037q-HN for bug-gnu-emacs@gnu.org; Sat, 19 Feb 2022 15:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nLWD4-0007d2-Bk for bug-gnu-emacs@gnu.org; Sat, 19 Feb 2022 15:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Feb 2022 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54062 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 54062-submit@debbugs.gnu.org id=B54062.164530197529284 (code B ref 54062); Sat, 19 Feb 2022 20:20:02 +0000 Original-Received: (at 54062) by debbugs.gnu.org; 19 Feb 2022 20:19:35 +0000 Original-Received: from localhost ([127.0.0.1]:58784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLWCc-0007cF-RE for submit@debbugs.gnu.org; Sat, 19 Feb 2022 15:19:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nLWCb-0007c3-7J for 54062@debbugs.gnu.org; Sat, 19 Feb 2022 15:19:33 -0500 Original-Received: from [2001:470:142:3::e] (port=40932 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLWCV-00032R-Vh; Sat, 19 Feb 2022 15:19:27 -0500 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=ukiEW5to9ZLQK2LAuBw4NaB5WwfHwPXScckEmxw2ZDw=; b=MVCD+6QabB22 CuMZHzczOtVMgy+m3cpv6Dn6gem6GIA1fFnR+peDhuD59U7dve9UisAMkTKckJFDyuBeFaSFEiBxG M3uqXawSpd+BIxLlyEG3vQHctSjNVkxMyQGFCUPqdFcq0ZDeliu6LgyUyt3S7E+d7vtiWLHbMhdmu TvQMkNFu/Uut1kXIyrg11utuQM7FmKXg7azsTbVW7/T2lHnr7IYpHsNxvaurEzyh1yCmYIwG2AhOX YAgJfItG1sYRQu2Ukcib4SnwcGBBUnLZs19D4bkJjT9+aTsb8DI2ZPsMHJbLDooV4+HRBt4nTYogr N/8WWArTLaPRt97a3H3GDQ==; Original-Received: from [87.69.77.57] (port=2588 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLWCV-00011z-K7; Sat, 19 Feb 2022 15:19:27 -0500 In-Reply-To: (message from Jim Porter on Sat, 19 Feb 2022 12:02:45 -0800) 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" Xref: news.gmane.io gmane.emacs.bugs:227205 Archived-At: > Cc: 54062@debbugs.gnu.org > From: Jim Porter > Date: Sat, 19 Feb 2022 12:02:45 -0800 > > > SIGPIPE isn't supported on MS-Windows, so I think we should have a > > fallback there for platforms that don't support SIGPIPE. > > Hmm, good point. Thinking about this some more, this also won't work for > Tramp (which only supports `interrupt-process' as far as I can tell). I > can think of a couple possible solutions. > > One option would be to call `interrupt-process' instead, since that > works in all cases I'm aware of. This isn't quite as nice as sending > SIGPIPE (or equivalent) to let the process handle it how it wants, but > at least `interrupt-process' has the same default behavior as SIGPIPE > (i.e. terminate the process). Many console programs catch SIGINT, though. Can't we terminate ("kill") the process instead? Or maybe deleting the process object is enough? > Another way would be to add a function like `process-break-pipe' (it > could probably use a better name) that would close the read end of the > process's output pipe, which - if I understand the Win32 API here - > should trigger the right behavior on MS Windows too. You mean, delete the process object? That's how we close our end of the pipe, no? > One caveat is that the head process (`yes' in the example), would only > see the "broken pipe" error on the *next* write after the one where > Eshell detected the broken pipe. That's easy enough to fix for cases > where we can signal SIGPIPE directly, but it's probably ok in general > too: after all, processes don't generally know exactly when a SIGPIPE > might occur, so it occurring slightly later shouldn't cause problems. I don't see a problem here. AFAIU, closing a pipe doesn't always deliver SIGPIPE, it can instead fail the write with EPIPE. So SIGPIPE is not guaranteed anyway. > (In theory, the tail process should call `process-break-pipe' as soon as > it closes, but in Eshell, the tail process doesn't know what's feeding > it input, so it can't easily do this.) Not sure I understand: an Emacs process object always knows what's feeding it.