From: Eli Zaretskii <eliz@gnu.org>
To: Markus Triska <triska@metalevel.at>
Cc: 63078@debbugs.gnu.org
Subject: bug#63078: 26.1; Sentinels are sometimes unexpectedly only invoked in script mode
Date: Wed, 26 Apr 2023 09:22:02 +0300 [thread overview]
Message-ID: <837ctzuprp.fsf@gnu.org> (raw)
In-Reply-To: <87wn1zpn8n.fsf@metalevel.at> (message from Markus Triska on Wed, 26 Apr 2023 01:15:36 +0200)
> From: Markus Triska <triska@metalevel.at>
> Date: Wed, 26 Apr 2023 01:15:36 +0200
>
> to reproduce this issue, please save the following C code in proc.c:
>
> #include <stdio.h>
> #include <stdlib.h>
> int main() {
> printf("hello");
> exit(0);
> }
>
> and compile it, yielding the program file "./proc":
>
> $ gcc proc.c -o proc
>
> Further, please store the following Elisp definitions in proc.el, in
> the same directory as the above program:
>
> (add-to-list 'exec-path ".")
>
> (defvar p-stopped nil)
>
> (defun my-sentinel (proc str)
> (when (string-match "^\\(?:finished\n\\|exited abnormally\\|killed\n\\)"
> str)
> (setq p-stopped t)))
>
> (defun wait-for-process-end (proc)
> (while (not p-stopped)
> (message "process status is: %s" (process-status proc))
> (accept-process-output proc 0.1 nil t)))
>
> (defun f ()
> (with-temp-buffer
> (let ((proc (start-process "p" (current-buffer) "proc")))
> (setq p-stopped nil)
> (set-process-sentinel proc 'my-sentinel)
> (wait-for-process-end proc))
> (message "process said: %s" (buffer-string))))
>
> The following invocation and result shows a case where the program
> behaves exactly as intended: It waits for the process sentinel to
> signal that no more output can arrive from the process, and shows the
> output it got while the process was producing output:
>
> $ emacs -Q --script proc.el --eval "(f)"
> process status is: exit
> process said: hello
>
> In contrast, the following invocation produces, in the echo area, the
> message "process status is: exit", and Emacs hangs unexpectedly:
>
> $ emacs -Q -l proc.el --eval "(f)"
>
> The behaviour I expect in this case is analogous to the other
> invocation: I do expect the message we see, followed by the message
> "process said: hello", as in the case above. However, this second
> message only appears if I manually interrupt Emacs with C-g.
I cannot reproduce the problem with Emacs 28.2: I get "process said:
hello" in the echo-area, as expected. Did you try with the -nw
command-line switch, and if you do, does it change anything?
It could be some timing problem: you start a program that exits almost
immediately, so there could be some race condition between the program
and your code.
next prev parent reply other threads:[~2023-04-26 6:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 23:15 bug#63078: 26.1; Sentinels are sometimes unexpectedly only invoked in script mode Markus Triska
2023-04-26 6:22 ` Eli Zaretskii [this message]
2023-04-26 17:58 ` Markus Triska
2023-04-26 6:52 ` Andreas Schwab
2023-04-26 18:00 ` Markus Triska
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=837ctzuprp.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=63078@debbugs.gnu.org \
--cc=triska@metalevel.at \
/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.