summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Pettersson <daniel@dpettersson.net>2024-04-23 18:58:06 +0200
committerEli Zaretskii <eliz@gnu.org>2024-04-27 12:15:33 +0300
commit3aed4400257a6762de96be37fa95357b5836363c (patch)
tree1bd4e7776f82c3f9ff32cfdd5238bfd0c272d195
parent4e17e0b84ae1a52a6032c83592bf958a1e26dea5 (diff)
downloademacs-3aed4400257a6762de96be37fa95357b5836363c.tar.gz
emacs-3aed4400257a6762de96be37fa95357b5836363c.tar.bz2
emacs-3aed4400257a6762de96be37fa95357b5836363c.zip
Shut down jsonrpc server more gracefully
* lisp/jsonrpc.el (jsonrpc-running-p): Avoid unnecessarily killing the server process. Suggested by Aaron Zeng <azeng@janestreet.com>. (Bug#70522)
-rw-r--r--lisp/jsonrpc.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 5037d8c5b2b..111e58cefe2 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -591,15 +591,18 @@ connection object, called when the process dies.")
(cl-defmethod jsonrpc-shutdown ((conn jsonrpc-process-connection)
&optional cleanup)
"Wait for JSONRPC connection CONN to shutdown.
-With optional CLEANUP, kill any associated buffers."
+With optional CLEANUP, kill any associated buffers.
+If CONN is not shutdown within an reasonable amount of time, warn
+and delete process."
(unwind-protect
(cl-loop
with proc = (jsonrpc--process conn) for i from 0
while (not (process-get proc 'jsonrpc-sentinel-cleanup-started))
unless (zerop i) do
(jsonrpc--warn "Sentinel for %s still hasn't run, deleting it!" proc)
- do
(delete-process proc)
+ do
+ ;; Let sentinel have a chance to run
(accept-process-output nil 0.1))
(when cleanup
(kill-buffer (process-buffer (jsonrpc--process conn)))