From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#48118: 27.1; 28; Only first process receives output with multiple running processes Date: Tue, 25 May 2021 20:02:57 +0200 Message-ID: <86tumq4rou.fsf@miha-pc> References: <86bl8z7sgk.fsf@miha-pc> <83im37cac6.fsf@gnu.org> <868s427sg1.fsf@miha-pc> <83pmxebuv7.fsf@gnu.org> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25288"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mail@daniel-mendler.de, larsi@gnus.org, 48118@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 25 19:58:12 2021 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 1llbJk-0006Lr-68 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 May 2021 19:58:12 +0200 Original-Received: from localhost ([::1]:40470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llbJj-0000XL-4F for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 May 2021 13:58:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llbJZ-0000T6-Vj for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 13:58:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llbJZ-0004Es-OO for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 13:58:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1llbJZ-0005PE-KP for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 13:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 May 2021 17:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48118 X-GNU-PR-Package: emacs Original-Received: via spool by 48118-submit@debbugs.gnu.org id=B48118.162196545920747 (code B ref 48118); Tue, 25 May 2021 17:58:01 +0000 Original-Received: (at 48118) by debbugs.gnu.org; 25 May 2021 17:57:39 +0000 Original-Received: from localhost ([127.0.0.1]:46705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llbJC-0005OY-Uj for submit@debbugs.gnu.org; Tue, 25 May 2021 13:57:39 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:34416 helo=mail.kamnitnik.top) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llbJA-0005OP-OC for 48118@debbugs.gnu.org; Tue, 25 May 2021 13:57:38 -0400 Original-Received: from localhost (unknown [IPv6:2a00:ee2:e04:9300:b7eb:7ae7:cc56:e0da]) by mail.kamnitnik.top (Postfix) with ESMTPSA id 315ABBBB83; Tue, 25 May 2021 17:57:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1621965455; bh=4hRZWDzf+K2/VmMs9F4XnC6YMWFT5MzHIKmbNsOgafM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mj/44UZHcQlvGK1fZ8s86z6pF1QhMOrcnbfNB/9bjWWfdC4mK8Ne3LLYEgNZLncWK us7hoxhBMZLbbxQzY8MWE8YFgaJYP+O7/t2auQ9tgeCASQHvqzIzzLKyfOBcgb87vp 8E4oB9tK+c7JUzfNZoGs8pal0BJ5ucQ1hwCOE9QnyY98UH7FuvnYMVqZmNas5Etj4W /yNudmAj3xkcJt4iSLjickmcHWvAFbKKI9sv3GtYjF9heexK71gtKfqmeOQnDvMNTW UjGc4n7Aay2btPxlOgqoyYIp4oanLlsG1LV6FSkrTiIanOFwxj8Zy8N60yFh4IndVV yCogdl8sFbjwA== In-Reply-To: <83pmxebuv7.fsf@gnu.org> 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:207228 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Eli Zaretskii writes: > The "+++" and "---" markers should be reversed. Whoops. >> + DEFVAR_LISP ("process-prioritize-lower-fds", Vprocess_prioritize_lower_fds, >> + doc: /* If nil, try to not prioritize reading from any process. >> +Emacs loops through file descriptors to receive data from subprocesses. After >> +accepting output from the first file descriptor with available data, restart the >> +loop from the file descriptor 0 if this option is non-nil. */); >> + Vprocess_prioritize_lower_fds = Qnil; > > Please use DEVAR_BOOL, since this is a boolean variable. Tanks for feedback, posting revised patch. --=-=-= Content-Type: #("text/x-patch" 0 12 (fontified nil)) Content-Disposition: inline; filename=0001-Try-to-not-prioritise-reading-from-lower-fds.patch Content-Transfer-Encoding: quoted-printable From=20d2cc936a1ce2c536abcb285ecf556988c8f4b4ec Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D 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. (syms_of_process): Vprocess_prioritize_lower_fds: New variable =2D-- etc/NEWS | 7 +++++++ src/process.c | 25 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 1541b74a3b..5bce2c7c88 100644 =2D-- a/etc/NEWS +++ b/etc/NEWS @@ -2705,6 +2705,13 @@ the Emacs Lisp reference manual for background. * Lisp Changes in Emacs 28.1 =20 +--- +** New variable 'process-prioritize-lower-fds' +When looping through file descriptors to handle subprocess output, try +to continue from where the previous loop left off instead of always +beginning from file descriptor zero. Set this variable to t to get +the old behaviour. + +++ ** New function 'sxhash-equal-including-properties'. This is identical to 'sxhash-equal' but accounting also for string diff --git a/src/process.c b/src/process.c index 47a2a6f1a3..ca19242afb 100644 =2D-- 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 =3D -1; int channel, nfds; fd_set Available; fd_set Writeok; @@ -5188,6 +5189,8 @@ wait_reading_process_output (intmax_t time_limit, int= nsecs, int read_kbd, while (1) { bool process_skipped =3D false; + bool wrapped; + int channel_start; =20 /* If calling from keyboard input, do not quit since we want to return C-g as an input character. @@ -5722,8 +5725,20 @@ wait_reading_process_output (intmax_t time_limit, in= t nsecs, int read_kbd, d->func (channel, d->data); } =20 =2D for (channel =3D 0; channel <=3D max_desc; channel++) + channel_start + =3D process_prioritize_lower_fds ? 0 : last_read_channel + 1; + + for (channel =3D channel_start, wrapped =3D false; + !wrapped || (channel < channel_start && channel <=3D max_desc); + channel++) { + if (channel > max_desc) + { + wrapped =3D true; + channel =3D -1; + continue; + } + if (FD_ISSET (channel, &Available) && ((fd_callback_info[channel].flags & (KEYBOARD_FD | PROCESS_FD)) =3D=3D PROCESS_FD)) @@ -5761,6 +5776,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 =3D channel; =20 if (do_display) redisplay_preserve_echo_area (12); @@ -8477,6 +8493,13 @@ syms_of_process (void) The variable takes effect when `start-process' is called. */); Vprocess_adaptive_read_buffering =3D Qt; =20 + DEFVAR_BOOL ("process-prioritize-lower-fds", process_prioritize_lower_fd= s, + doc: /* If nil, try to not prioritize reading from any process. +Emacs loops through file descriptors to receive data from subprocesses. A= fter +accepting output from the first file descriptor with available data, resta= rt the +loop from the file descriptor 0 if this option is non-nil. */); + process_prioritize_lower_fds =3D 0; + DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions, doc: /* List of functions to be called for `interrupt-process'. The arguments of the functions are the same as for `interrupt-process'. =2D-=20 2.31.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmCtO9ETHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP8rxEAC+qT4g41i5/WvbAePpwrjxsIO2VTbh pIp1GOAoI/05BOprwBjxzvkgq66Xp1c9DAkEXxps86jU8UTUL+YYzWOhVmfUk9sG nUtXbGnfb5MKSe/ztYQDWtLdgmo4xm8yI4djYbhWIKjAKcp93bqQZuILdoqp1fjK yot1/nlnybPQkyXQFpcaMojsfL1e4U86C59PGdhU0LqnWn7K2KJE0V3PalOJnYm/ CPYgZVJUKJIy8TBgSkLj+6VrWrddSRx9Em0lJAkswE1lEKEfqN3cwgmS6i5/oBTO wiw9Vvy00jSPZzG4PdQuS8p4AF0/CXIYy3ctRkzNFFBaxBwZXWnx613vK+BMKM8B rO2JOL9z2mE68qTfy0eY/Y8yE4xRycgg37wOVKJ6XSJF0yDjcIevfRPPP3m8Gt87 2Gzd0XRXSxH9OBFclqvjL/7I+3Gce4AdCT1zS1HsAGl9VX0UeOR17xconEzsDliE IIz3XoG21Mh2x/G4vTGOuUf6AGzSlkETaDCpHT4dS08Pz4Tnh5QvMdvxxW7RAyZy J24q5TzNxZv1jSxCYj7rLbj45bA+00QnrxOMUBrNOqGlaSCTv7oQQFP2SgtzvoV0 fiXfmwql3PB48w4zznAlwI3o1ugGj00iEJYi1Yov8jxUULknigY5aDJzTarmRG1z L4gRrT8t0ZsD+g== =YyGq -----END PGP SIGNATURE----- --==-=-=--