magit/with-editor

server-running-p

Closed this issue · 2 comments

Re: https://lists.gnu.org/archive/html/bug-gnu-emacs/2018-06/msg00720.html
maybe the uses of server-running-p should be changed. E.g.

(when (server-running-p server-name)

will return non-nil if server-running-p gave up determining if the server was running.

will return non-nil

In which case the server is started, possibly killing the server of another emacs instance. This is fine since the primary requirement and goal is to make sure that the current instance runs a server. By using server-running-p we might be able to avoid killing another instance's server, which of course isn't as nice as knowing that we won't be doing that. However the alternative of always killing the other server (if any) is less desirable than either. This is why we use server-running-p.

Whether the current instance is running a server can be tested using (process-live-p server-process), which is what we do.

    ;; Make sure the server is running.
    (unless (process-live-p server-process)
      (when (server-running-p server-name)
        (setq server-name (format "server%s" (emacs-pid)))
        (when (server-running-p server-name)
          (server-force-delete server-name)))
      (server-start))

Unless you actually experience some issue I don't think there is anything to worry about here.