From: Eli Zaretskii <eliz@gnu.org>
To: mail@lucaswerkmeister.de, eggert@cs.ucla.edu
Cc: larsi@gnus.org, 65156@debbugs.gnu.org
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 [thread overview]
Message-ID: <83cyzxmj1g.fsf@gnu.org> (raw)
In-Reply-To: <83fs4tmlik.fsf@gnu.org> (message from Eli Zaretskii on Tue, 08 Aug 2023 21:33:55 +0300)
> Cc: 65156@debbugs.gnu.org
> Date: Tue, 08 Aug 2023 21:33:55 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Tue, 8 Aug 2023 20:20:23 +0200
> > From: Lucas Werkmeister <mail@lucaswerkmeister.de>
> >
> > 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;
}
next prev parent reply other threads:[~2023-08-08 19:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 18:20 bug#65156: 29.1; Reading from pipe with --insert or insert-file-contents no longer supported Lucas Werkmeister
2023-08-08 18:33 ` Eli Zaretskii
2023-08-08 19:27 ` Eli Zaretskii [this message]
2023-08-09 2:47 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-09 11:31 ` Eli Zaretskii
2023-08-09 20:57 ` Paul Eggert
2023-08-10 5:17 ` Eli Zaretskii
2023-08-10 6:08 ` Paul Eggert
2023-08-10 8:15 ` Eli Zaretskii
2023-08-11 17:18 ` Paul Eggert
2023-08-11 18:30 ` Eli Zaretskii
2023-08-11 21:45 ` Paul Eggert
2023-08-12 8:05 ` Eli Zaretskii
2023-08-12 8:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-09 8:07 ` Mattias Engdegård
2023-08-09 8:15 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-09 8:29 ` Mattias Engdegård
2023-08-09 12:00 ` Eli Zaretskii
2023-08-09 12:03 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83cyzxmj1g.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=65156@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=larsi@gnus.org \
--cc=mail@lucaswerkmeister.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.