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#65156: 29.1; Reading from pipe with --insert or insert-file-contents no longer supported Date: Tue, 08 Aug 2023 22:27:23 +0300 Message-ID: <83cyzxmj1g.fsf@gnu.org> References: <4b873c29-e8ca-403c-bd37-a531d93661f3@lucaswerkmeister.de> <83fs4tmlik.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1326"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 65156@debbugs.gnu.org To: mail@lucaswerkmeister.de, eggert@cs.ucla.edu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 08 21:28:24 2023 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 1qTSNT-0000A5-71 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Aug 2023 21:28:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTSN9-0007wP-Oq; Tue, 08 Aug 2023 15:28:03 -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 1qTSN8-0007wG-OU for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2023 15:28:02 -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 1qTSN8-0003gT-GY for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2023 15:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qTSN7-0004Kx-Q2 for bug-gnu-emacs@gnu.org; Tue, 08 Aug 2023 15:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Aug 2023 19:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65156 X-GNU-PR-Package: emacs Original-Received: via spool by 65156-submit@debbugs.gnu.org id=B65156.169152283216610 (code B ref 65156); Tue, 08 Aug 2023 19:28:01 +0000 Original-Received: (at 65156) by debbugs.gnu.org; 8 Aug 2023 19:27:12 +0000 Original-Received: from localhost ([127.0.0.1]:37795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qTSMK-0004Jp-3j for submit@debbugs.gnu.org; Tue, 08 Aug 2023 15:27:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qTSMH-0004Ja-2C for 65156@debbugs.gnu.org; Tue, 08 Aug 2023 15:27:10 -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 1qTSM9-0003bc-LO; Tue, 08 Aug 2023 15:27:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=20YX/cGQ+74SbGulqC7htGk+/UxnfoPGMu+2uV3QHcw=; b=MiVEVySM12IM3a8ow/2M +tfKj7XRZ3NWUJBt3+Zx0zVW8AulbMS/v3fOS1L5cdXJWluzipcG2xqNHx+0IAjwDO4r8X0vvtBL1 VVmyyc3WW+v5+bosowXGc4EoiGLiJpp7pRTDXhAv9pYOC5l3y1TD0N1JrLLbGvEq8epdL8BVEPsyc XhcuHbj7oX3e5PRMZfkiQw+umBoIQD0KHYC6G5+RYTNQfAxySCUpChkPVYHL0IcOwAz7JVmwr95eE esFvSZdOVCLh/EJhXrpbUdnyQIUBAG4mVWsSEIZY8yapJ5gAHAK4UgeDY/ECocGa0R467WNWD/C0C eAGcddJI1JhmSw==; In-Reply-To: <83fs4tmlik.fsf@gnu.org> (message from Eli Zaretskii on Tue, 08 Aug 2023 21:33:55 +0300) 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:266986 Archived-At: > Cc: 65156@debbugs.gnu.org > Date: Tue, 08 Aug 2023 21:33:55 +0300 > From: Eli Zaretskii > > > Date: Tue, 8 Aug 2023 20:20:23 +0200 > > From: Lucas Werkmeister > > > > Launch graphical Emacs with standard input attached to a pipe, then > > attempt to insert /dev/stdin, for example: > > > > echo test | emacs -Q --insert /dev/stdin > > echo test | emacs -Q --eval '(insert-file-contents "/dev/stdin")' > > > > This now results in an error (and nothing inserted into the buffer): > > "Maximum buffer size exceeded". > > The doc string says: > > When inserting data from a special file (e.g., /dev/urandom), you > can’t specify VISIT or BEG, and END should be specified to avoid > inserting unlimited data into the buffer. > > > Previously, this used to work; git bisect identifies cb4579ed6b ("Allow > > inserting parts of /dev/urandom with insert-file-contents", bug#18370) > > as the first bad commit. > > > > Other (non-stdin) pipes are also affected. Testing with a named pipe > > shows that the error only occurs after the pipe is first written to: > > > > # first terminal: > > mkfifo /tmp/fifo > > emacs -Q > > M-x insert-file /tmp/fifo > > # second terminal: > > { echo x; sleep 10; echo y; } > /tmp/fifo > > > > Before you run the command in the second terminal, you can observe that > > Emacs is just waiting for input from the pipe; as soon as you run the > > other command, Emacs shows the error before the sleep finishes. > > Lars, Paul, any suggestions? I installed the patch below on the emacs-29 branch; please see if it solves your problems with reading from pipes. Paul, can there be a regular file that is not seekable? If regular files are always seekable, the patch can be simplified. diff --git a/src/fileio.c b/src/fileio.c index 995e414..55132f1 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4581,7 +4581,7 @@ because (1) it preserves some marker positions (in unchanged portions goto handled; } - if (seekable || !NILP (end)) + if ((seekable && regular) || !NILP (end)) total = end_offset - beg_offset; else /* For a special file, all we can do is guess. */ @@ -4678,7 +4678,7 @@ because (1) it preserves some marker positions (in unchanged portions For a special file, where TOTAL is just a buffer size, so don't bother counting in HOW_MUCH. (INSERTED is where we count the number of characters inserted.) */ - if (seekable || !NILP (end)) + if ((seekable && regular) || !NILP (end)) how_much += this; inserted += this; }