Function: server-stop
server-stop is a byte-compiled function defined in server.el.gz.
Signature
(server-stop &optional NOFRAME)
Documentation
If this Emacs process has a server communication subprocess, stop it.
If this actually stopped the server, return non-nil. If the
server is running in some other Emacs process (see
server-running-p), signal a server-running-external error.
If NOFRAME is non-nil, don't delete any existing frames associated with a client process. This is useful, for example, when killing Emacs, in which case the frames will get deleted anyway.
Source Code
;; Defined in /usr/src/emacs/lisp/server.el.gz
(defun server-stop (&optional noframe)
"If this Emacs process has a server communication subprocess, stop it.
If this actually stopped the server, return non-nil. If the
server is running in some other Emacs process (see
`server-running-p'), signal a `server-running-external' error.
If NOFRAME is non-nil, don't delete any existing frames
associated with a client process. This is useful, for example,
when killing Emacs, in which case the frames will get deleted
anyway."
(let ((server-file (server--file-name))
stopped-p)
(when server-process
;; Kill it dead!
(ignore-errors (delete-process server-process))
(server-log "Stopped server")
(setq stopped-p t
server-process nil
server-mode nil
global-minor-modes (delq 'server-mode global-minor-modes)))
(unwind-protect
;; Delete the socket files made by previous server
;; invocations.
(if (not (eq t (server-running-p server-name)))
;; Remove any leftover socket or authentication file.
(ignore-errors
(let (delete-by-moving-to-trash)
(delete-file server-file)
;; Also delete the directory that the server file was
;; created in -- but only in /tmp (see bug#44644).
;; There may be other servers running, too, so this may
;; fail.
(when (equal (file-name-directory
(directory-file-name
(file-name-directory server-file)))
"/tmp/")
(ignore-errors
(delete-directory (file-name-directory server-file))))))
(signal 'server-running-external
(list (format "There is an existing Emacs server, named %S"
server-name))))
;; If this Emacs already had a server, clear out associated status.
(while server-clients
(server-delete-client (car server-clients) noframe)))
stopped-p))