Function: server-running-p

server-running-p is a byte-compiled function defined in server.el.gz.

Signature

(server-running-p &optional NAME)

Documentation

Test whether server NAME is running.

Return values:
  nil the server is definitely not running.
  t the server seems to be running.
  something else we cannot determine whether it's running without using
                   commands which may have to wait for a long time.

This function can return non-nil if the server was started by some other Emacs process. To check from a Lisp program whether a server was started by the current Emacs process, use the server-process variable.

Source Code

;; Defined in /usr/src/emacs/lisp/server.el.gz
(defun server-running-p (&optional name)
  "Test whether server NAME is running.

Return values:
  nil              the server is definitely not running.
  t                the server seems to be running.
  something else   we cannot determine whether it's running without using
                   commands which may have to wait for a long time.

This function can return non-nil if the server was started by some other
Emacs process.  To check from a Lisp program whether a server was started
by the current Emacs process, use the `server-process' variable."
  (unless name (setq name server-name))
  (condition-case nil
      (if server-use-tcp
	  (with-temp-buffer
	    (insert-file-contents-literally (expand-file-name name server-auth-dir))
	    (or (and (looking-at "127\\.0\\.0\\.1:[0-9]+ \\([0-9]+\\)")
		     (assq 'comm
			   (process-attributes
			    (string-to-number (match-string 1))))
		     t)
		:other))
	(delete-process
	 (make-network-process
	  :name "server-client-test" :family 'local :server nil :noquery t
	  :service (expand-file-name name server-socket-dir)))
	t)
    (file-error nil)))