From: Markus Triska <triska@metalevel.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 63078@debbugs.gnu.org
Subject: bug#63078: 26.1; Sentinels are sometimes unexpectedly only invoked in script mode
Date: Wed, 26 Apr 2023 19:58:54 +0200 [thread overview]
Message-ID: <87r0s6frtt.fsf@metalevel.at> (raw)
In-Reply-To: <837ctzuprp.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 26 Apr 2023 09:22:02 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
> 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.
I can reproduce the problem also with Emacs 28.8, and yes, I also
believe this may be a timing issue: I have now constructed a test case
that exhibits the issue also when the "-nw" option is used. To
reproduce, please start Emacs with:
$ emacs -Q
or with:
$ emacs -Q -nw
and then place the forms below in a buffer, and then evaluate the buffer
contents with M-x eval-buffer RET. The bash shell is used as external
process, the sample C program I originally included is no longer needed.
>
The expected output of the forms below is an endless stream of messages
of the form:
trying to elicit race condition at (25673 25753 287220 854000)
process status is: run [2 times]
process said: hi
failed
trying to elicit race condition at (25673 25753 289270 703000)
process status is: run [2 times]
process said: hi
failed
i.e., the expected case is that *no* race condition exists, and
therefore eliciting the issue *fails*, which is the desired result as
long as the program runs.
However, after I few seconds, this expected sequence of messages stops,
and only the following message is then emitted over and over:
process status is: exit
When this occurs, it means that the sentinel was unexpectedly not
invoked when the process stops, in contrast to all preceding cases where
the sentinel was invoked as expected when the process terminates.
Running the program in script mode yields the expected result over and
over, I cannot elicit the issue with the --script option of Emacs.
I hope this helps. Can you reproduce the issue with this example?
Thank you and all the best,
Markus
(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 elicit-issue ()
(with-temp-buffer
(let ((proc (start-process "p" (current-buffer) "bash" "-c" "echo -n hi")))
(setq p-stopped nil)
(set-process-sentinel proc 'my-sentinel)
(wait-for-process-end proc))
(message "process said: %s" (buffer-string))))
(while t
(message "trying to elicit race condition at %s" (current-time))
(elicit-issue)
(message "failed"))
next prev parent reply other threads:[~2023-04-26 17:58 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
2023-04-26 17:58 ` Markus Triska [this message]
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=87r0s6frtt.fsf@metalevel.at \
--to=triska@metalevel.at \
--cc=63078@debbugs.gnu.org \
--cc=eliz@gnu.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 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.