help-gnu-emacs
[Top][All Lists]
Advanced

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

check if another emacs instance is running


From: harven
Subject: check if another emacs instance is running
Date: Sun, 29 Nov 2009 13:22:28 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Is there a function that checks if another instance of emacs 
is currently running ?

I didn't find anything. Yet there is a command that tests if a server
is running, and it seems to be reliable (works on all architectures, does not
depend on the way the server was started). Unfortunately I don't see how
it can be modified so as to detect emacs instances. I tried some workarounds
but none seems to be very satisfying.

  Use some external utility to list current processes e.g.
  (when (< 1 (string-to-number 
              (shell-command-to-string "ps -A |grep -c emacs23")))
    (message "ok"))
  ;; but this is system-specific.

  Set an environment variable from emacs at start
  ;; won't detect instances launched as emacs -Q.

  Open a file and see if there is a lock
  ;; I had a look at userlock.el but did not understand how it works.



reply via email to

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