emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lost socket for detached Emacs, how to regain control?


From: Juanma Barranquero
Subject: Re: Lost socket for detached Emacs, how to regain control?
Date: Thu, 6 Nov 2008 10:47:25 +0100

On Thu, Nov 6, 2008 at 02:31, Stefan Monnier <address@hidden> wrote:

> Another option is for server-start to
> try and detect that there's already an active socket (using
> server-running-p) and refuse to start.

That would be useful even for local servers using TCP sockets, but
server-running-p currently does work only for local sockets.

The following is a simple way to at least know whether there's a
process called Emacs with the same pid that is stored in the
authentication file.

(with-temp-buffer
  (insert-file-contents-literally (expand-file-name server-name
server-auth-dir))
  (skip-chars-forward "0-9:.")
  (let ((case-fold-search t)
        (proc (assq 'comm (system-process-attributes (read (point-marker))))))
    (and proc
         (string-match-p "emacs" (cdr proc)))))

  Juanma




reply via email to

[Prev in Thread] Current Thread [Next in Thread]