Function: jsonrpc--process-sentinel

jsonrpc--process-sentinel is a byte-compiled function defined in jsonrpc.el.gz.

Signature

(jsonrpc--process-sentinel PROC CHANGE)

Documentation

Called when PROC undergoes CHANGE.

Source Code

;; Defined in /usr/src/emacs/lisp/jsonrpc.el.gz
(defun jsonrpc--process-sentinel (proc change)
  "Called when PROC undergoes CHANGE."
  (let ((connection (process-get proc 'jsonrpc-connection)))
    (jsonrpc--debug connection "Connection state change: `%s'" change)
    (when (not (process-live-p proc))
      (with-current-buffer (jsonrpc-events-buffer connection)
        (let ((inhibit-read-only t))
          (insert "\n----------b---y---e---b---y---e----------\n")))
      ;; Cancel outstanding timers
      (mapc (jsonrpc-lambda (_id _method _success-fn _error-fn timer)
              (when timer (cancel-timer timer)))
            (jsonrpc--continuations connection))
      (maphash (lambda (_ triplet)
                 (pcase-let ((`(,_ ,timer ,_) triplet))
                   (when timer (cancel-timer timer))))
               (jsonrpc--deferred-actions connection))
      (process-put proc 'jsonrpc-sentinel-cleanup-started t)
      (unwind-protect
          ;; Call all outstanding error handlers
          (mapc (jsonrpc-lambda (_id _method _success-fn error-fn _timer)
                  (funcall error-fn '(:code -1 :message "Server died")))
                (jsonrpc--continuations connection))
        (jsonrpc--message "Server exited with status %s" (process-exit-status proc))
        (delete-process proc)
        (when-let* ((p (slot-value connection '-autoport-inferior))) (delete-process p))
        (funcall (jsonrpc--on-shutdown connection) connection)))))