Function: nrepl-server-sentinel
nrepl-server-sentinel is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl-server-sentinel PROCESS EVENT)
Documentation
Handle nREPL server PROCESS EVENT.
If the nREPL PROCESS failed to initiate and encountered a fatal EVENT
signal, raise an error. Additionally, if the EVENT signal is SIGHUP,
close any existing client connections.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/nrepl-client.el
(defun nrepl-server-sentinel (process event)
"Handle nREPL server PROCESS EVENT.
If the nREPL PROCESS failed to initiate and encountered a fatal EVENT
signal, raise an `error'. Additionally, if the EVENT signal is SIGHUP,
close any existing client connections."
;; only interested on fatal signals.
(unless (process-live-p process)
(emacs-bug-46284/when-27.1-windows-nt
;; There is a bug in emacs 27.1 (since fixed) that sets all EVENT
;; descriptions for signals to "unknown signal". We correct this by
;; resetting it back to its canonical value.
(when (eq (process-status process) 'signal)
(pcase (process-exit-status process)
;; SIGHUP==1 emacs nt/inc/ms-w32.h
(1 (setq event "Hangup"))
;; SIGINT==2 x86_64-w64-mingw32/include/signal.h
(2 (setq event "Interrupt"))
;; SIGKILL==9 emacs nt/inc/ms-w32.h
(9 (setq event "Killed")))))
(let* ((server-buffer (process-buffer process))
(clients (seq-filter (lambda (b)
(eq (buffer-local-value 'nrepl-server-buffer b)
server-buffer))
(buffer-list))))
;; see https://github.com/clojure-emacs/cider/pull/3333
(when (string-match-p "^hangup" event)
(mapc #'cider--close-connection clients))
(if (process-get process :cider--nrepl-server-ready)
(progn
(when server-buffer (kill-buffer server-buffer))
(message "nREPL server exited."))
(let ((problem (when (and server-buffer (buffer-live-p server-buffer))
(with-current-buffer server-buffer
(buffer-substring (point-min) (point-max))))))
(error "Could not start nREPL server: %s (%S)" problem (string-trim event)))))))