Ok, this issue I'm running into seems pretty weird. I'm running an async process during init and I have set a process sentinel to tell me when it exits. This works fine in terminal Emacs but in GUI Emacs the process sentinel never runs.
Here is a minimal working example:
(setq my/test-flag nil)
(defun my/test-sentinel (proc &optional _change)
(setq my/test-flag t))
(let* ((name "test")
(buf (generate-new-buffer (concat "*" name "*")))
(proc (let ((process-connection-type nil))
(apply #'start-process name buf "sleep" '("3")))))
(set-process-sentinel proc #'my/test-sentinel)
(while (not my/test-flag)
(sleep-for 0.05)))
If you put this in init.el and run terminal Emacs, it will hang for 3 seconds as expected before continuing on. GUI Emacs, on the other hand, will hang forever, indicating that my/test-sentinel is never run, even though the process does finish after 3 seconds.
Background info:
- I am using Emacs 27.1 from the Arch Linux repositories.
- I failed to reproduce this on macOS using the
emacsCask. - Replacing
sleep-forwithaccept-process-outputgives the same result. - If the snippet is run by the user after init, the sentinel runs as expected in GUI Emacs.
- This issue arose while debugging use of
async-waitfrom theasyncpackage during init.
my/test-flagist.emacs -q -l foo.elwherefoo.elcontains just the code above.debug-on-quitand added a debugging print of(process-list)in the loop: the test process appears in that output for as long as I wait: after pressingC-gI callprocess-listand it returns nil.