From: Helmut Eller <eller.helmut@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 51177@debbugs.gnu.org
Subject: bug#51177: 29.0.50; stop-process on pipes
Date: Fri, 12 Nov 2021 06:13:42 +0100 [thread overview]
Message-ID: <m24k8iklbt.fsf@gmail.com> (raw)
In-Reply-To: <87k0he2ghr.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 12 Nov 2021 04:35:28 +0100")
[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]
On Fri, Nov 12 2021, Lars Ingebrigtsen wrote:
>> However, I would like to propose
>> that, in status_notify, the sentinel function should be called before
>> closing the file descriptors. That way, the sentinel can read the
>> buffered output as suggested in the example.
>
> A sentinel usually doesn't read anything...
The idea is that the sentinel does something like this:
(lambda (p _)
(set-process-filter p filter)
(while (accept-process-output p 0)))
First, it changes the filter from t to an actual function. Then it
calls accept-process-output. This in turn polls the file descriptors
and calls the filter function if there is buffered output. If there is
no buffered output to read, then accept-process-output returns nil and
the while loop terminates.
All this happens after the process has terminated. Granted, not a
particularly intuitive API.
However, the required change would be rather small, I think. The patch
below shows how this could be done. It basically moves the part that
closes the file descriptors after the call to exec_sentinel.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sentinel.patch --]
[-- Type: text/x-diff, Size: 1377 bytes --]
diff --git a/src/process.c b/src/process.c
index f923aff1cb..bc236c7e4c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1341,6 +1341,9 @@ The string argument is normally a multibyte string, except:
&& !EQ (p->command, Qt))
add_process_read_fd (p->infd);
}
+ else {
+ fprintf (stderr, "p->infd < 0 in Fset_process_filter\n");
+ }
pset_filter (p, filter);
@@ -7536,15 +7539,6 @@ status_notify (struct Lisp_Process *deleting_process,
if (CONSP (p->status))
symbol = XCAR (p->status);
- if (EQ (symbol, Qsignal) || EQ (symbol, Qexit)
- || EQ (symbol, Qclosed))
- {
- if (delete_exited_processes)
- remove_process (proc);
- else
- deactivate_process (proc);
- }
-
/* The actions above may have further incremented p->tick.
So set p->update_tick again so that an error in the sentinel will
not cause this code to be run again. */
@@ -7554,6 +7548,16 @@ status_notify (struct Lisp_Process *deleting_process,
if (BUFFERP (p->buffer))
/* In case it uses %s in mode-line-format. */
bset_update_mode_line (XBUFFER (p->buffer));
+
+ if (EQ (symbol, Qsignal) || EQ (symbol, Qexit)
+ || EQ (symbol, Qclosed))
+ {
+ if (delete_exited_processes)
+ remove_process (proc);
+ else
+ deactivate_process (proc);
+ }
+
}
} /* end for */
next prev parent reply other threads:[~2021-11-12 5:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 9:20 bug#51177: 29.0.50; stop-process on pipes Helmut Eller
2021-10-13 11:45 ` Lars Ingebrigtsen
2021-10-13 13:39 ` Helmut Eller
2021-10-13 13:01 ` Eli Zaretskii
2021-10-13 14:04 ` Helmut Eller
2021-10-14 7:51 ` jakanakaevangeli
2021-10-14 8:00 ` Helmut Eller
2021-10-14 11:10 ` Lars Ingebrigtsen
2021-10-16 16:24 ` Helmut Eller
2021-10-16 16:47 ` Eli Zaretskii
2021-10-16 17:07 ` Helmut Eller
2021-10-18 6:58 ` Lars Ingebrigtsen
2021-11-11 19:47 ` Helmut Eller
2021-11-12 3:35 ` Lars Ingebrigtsen
2021-11-12 5:13 ` Helmut Eller [this message]
2021-11-12 6:30 ` Lars Ingebrigtsen
2021-11-12 7:21 ` Eli Zaretskii
2021-11-12 8:28 ` Helmut Eller
2021-11-12 12:00 ` Eli Zaretskii
2021-11-12 12:34 ` Helmut Eller
2021-11-12 13:05 ` Eli Zaretskii
2021-11-12 13:26 ` Helmut Eller
2021-11-12 12:58 ` Helmut Eller
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24k8iklbt.fsf@gmail.com \
--to=eller.helmut@gmail.com \
--cc=51177@debbugs.gnu.org \
--cc=larsi@gnus.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).