Function: nrepl--port-alive-p

nrepl--port-alive-p is a byte-compiled function defined in nrepl-client.el.

Signature

(nrepl--port-alive-p PORT-NUMBER)

Documentation

Return non-nil unless PORT-NUMBER can be shown to have no listener.

Checks for a listening TCP socket with lsof; errs on the side of liveness when that cannot be determined (Windows, or no lsof - minimal systems often lack it, and absence of the tool is not evidence the port is dead). process-file-shell-command honors default-directory and so runs lsof on the remote host in TRAMP contexts.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-client.el
(defun nrepl--port-alive-p (port-number)
  "Return non-nil unless PORT-NUMBER can be shown to have no listener.
Checks for a listening TCP socket with lsof; errs on the side of
liveness when that cannot be determined (Windows, or no lsof - minimal
systems often lack it, and absence of the tool is not evidence the
port is dead).  `process-file-shell-command' honors `default-directory'
and so runs lsof on the remote host in TRAMP contexts."
  (if (or (eq system-type 'windows-nt)
          (not (executable-find "lsof" (file-remote-p default-directory))))
      t
    ;; -sTCP:LISTEN: only a listening socket proves a live server; a
    ;; mere established connection involving the port does not.
    (not (equal ""
                (with-temp-buffer
                  (process-file-shell-command
                   (format "lsof -i:%s -sTCP:LISTEN" port-number) nil t)
                  (buffer-string))))))