[Top][All Lists]

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

How to detect two emacs process in Elisp code?

From: address@hidden
Subject: How to detect two emacs process in Elisp code?
Date: Sat, 18 Jul 2020 13:55:49 +0800

I load desktop-save-mode session in init.el. But when using
"bug-hunter-init-file", I need to exclude this session init file.

Here is my try:

#+begin_src emacs-lisp
;;; detect external system has Emacs process running?
;;; If yes, like `bug-hunter' is running. Then don't load session.
(let ((emacs-processes
       (length (mapcar
                 (lambda (str)
                   (not (string-empty-p str)))
                  ;; (shell-command-to-string "ps -C emacs -o pid=")
                  (shell-command-to-string "ps -C emacs -o pid=")
  (when (<= emacs-processes 1)
    (message "init-emacs-session loading")
    (require 'init-emacs-session)))

The upper code has a problem, the command "ps -C emacs -o pid=" can't detect
emacs program name like "emacs-28.2.3" which is in /usr/local/bin and
compiled from source code.

Does anyone has good solution for this? Thanks in advance.

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433

reply via email to

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