[Top][All Lists]

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

Re: error in server-running-p on M$

From: Juanma Barranquero
Subject: Re: error in server-running-p on M$
Date: Sat, 22 Nov 2008 14:37:02 +0100

On Sat, Nov 22, 2008 at 14:20, Eli Zaretskii <address@hidden> wrote:

> Perhaps we should use the bug tracker for tracking issues as well, not
> just bug reports.

I think so.

> In that thread, Stefan answered it.

He said: "Currently it's not used (except in some people's .emacs).
The intended use is in start-server to try and prevent hijacking the
socket of a pre-existing server."  But that is just part of the
answer, I think.

> Can you point me to these changes, or post them?  I don't think I saw
> any diffs in that thread.

I didn't send any diffs, just posted a little snippet of code, because
the change is almost trivial. See the attached patch, which
illustrates the problem I'm talking about.

> Sorry, I don't follow: how is this related to the issue at hand?

Because, if the only intent of `server-running-p' is to "prevent
hijacking the socket" of another server, the name is quite misleading.
It does not detect (even now, for local sockets) whether another
instance is running; it only detects whether another instance is
running _with_the_same_server_setup_ (presumably because the intention
is not disturbing it).

That's why I ask about two consecutive instances of Emacs using
different names, or switching from local to TCP sockets.
`server-running-p' won't detect the first one. If that is the intended
effect, then the function should be called


Index: lisp/server.el
RCS file: /sources/emacs/emacs/lisp/server.el,v
retrieving revision 1.173
diff -u -2 -r1.173 server.el
--- lisp/server.el      5 Nov 2008 21:16:17 -0000       1.173
+++ lisp/server.el      7 Nov 2008 15:37:36 -0000
@@ -537,5 +537,15 @@
   (unless name (setq name server-name))
   (condition-case nil
-      (progn
+      (if server-use-tcp
+         (with-temp-buffer
+           (insert-file-contents-literally
+            (expand-file-name server-name server-auth-dir))
+           (and (looking-at "127\.0\.0\.1:[0-9]+ \\([0-9]+\\)")
+                (let ((case-fold-search t)
+                      (proc (assq 'comm
+                                  (system-process-attributes
+                                   (string-to-number (match-string 1))))))
+                  (and proc
+                       (string-match-p "emacs" (cdr proc))))))

reply via email to

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