GNU bug report logs - #48118
27.1; 28; Only first process receives output with multiple running processes

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Fri, 30 Apr 2021 13:45:02 UTC

Severity: normal

Tags: fixed

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #53 received at 48118 <at> debbugs.gnu.org (full text, mbox):

From: miha <at> kamnitnik.top
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: mail <at> daniel-mendler.de, eliz <at> gnu.org, 48118 <at> debbugs.gnu.org
Subject: Re: bug#48118: 27.1; 28; Only first process receives output with
 multiple running processes
Date: Mon, 24 May 2021 23:05:47 +0200
[Message part 1 (text/plain, inline)]
I propose the following simple patch. It makes output from multiple
/bin/yes programs arrive at the same rate and multiple grep processes
can run without them seemingly blocking each other.


[0001-Try-to-not-prioritise-reading-from-lower-fds.patch (text/x-patch, inline)]
From 29544585ec07ec180bb13fac9142d3755c597cd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miha=20Rihtar=C5=A1i=C4=8D?= <miha <at> kamnitnik.top>
Date: Mon, 24 May 2021 22:46:47 +0200
Subject: [PATCH] Try to not prioritise reading from lower fds

* src/process.c (wait_reading_process_output): When looping through
fds, continue from where we left off.
---
 src/process.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/process.c b/src/process.c
index 47a2a6f1a3..9c2f328ebc 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5134,6 +5134,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
 			     Lisp_Object wait_for_cell,
 			     struct Lisp_Process *wait_proc, int just_wait_proc)
 {
+  static int last_read_channel = -1;
   int channel, nfds;
   fd_set Available;
   fd_set Writeok;
@@ -5188,6 +5189,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
   while (1)
     {
       bool process_skipped = false;
+      bool wrapped;
 
       /* If calling from keyboard input, do not quit
 	 since we want to return C-g as an input character.
@@ -5722,8 +5724,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
             d->func (channel, d->data);
 	}
 
-      for (channel = 0; channel <= max_desc; channel++)
-	{
+      for (channel = last_read_channel + 1, wrapped = false;
+	   !wrapped || (channel <= last_read_channel && channel <= max_desc);
+	   channel++)
+        {
+	  if (channel > max_desc)
+	    {
+	      wrapped = true;
+	      channel = -1;
+	      continue;
+	    }
+
 	  if (FD_ISSET (channel, &Available)
 	      && ((fd_callback_info[channel].flags & (KEYBOARD_FD | PROCESS_FD))
 		  == PROCESS_FD))
@@ -5761,6 +5772,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
 		     don't try to read from any other processes
 		     before doing the select again.  */
 		  FD_ZERO (&Available);
+		  last_read_channel = channel;
 
 		  if (do_display)
 		    redisplay_preserve_echo_area (12);
-- 
2.31.1

[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 3 years and 349 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.