From c1300397f86a397ae38ad08126dc8e021067f128 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 24 Sep 2023 01:29:18 +0300 Subject: [PATCH 3/3] Dynamically increase the readmax if the pipe has more available * src/process.c (read_process_output): Dynamically increase the buffer size depending on the pipe's buffered contents (bug#66020). --- src/process.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/process.c b/src/process.c index d7aedcdf12d..13cf6d6c50d 100644 --- a/src/process.c +++ b/src/process.c @@ -6146,6 +6146,17 @@ read_process_output (Lisp_Object proc, int channel) Lisp_Object odeactivate; char *chars; +#ifdef USABLE_FIONREAD +#ifdef DATAGRAM_SOCKETS + if (!DATAGRAM_CHAN_P (channel)) +#endif + { + int available_read; + ioctl (p->infd, FIONREAD, &available_read); + readmax = MAX (readmax, available_read); + } +#endif + USE_SAFE_ALLOCA; chars = SAFE_ALLOCA (sizeof coding->carryover + readmax); -- 2.37.2