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

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

How to detect two emacs process in Elisp code?


From: stardiviner
Subject: How to detect two emacs process in Elisp code?
Date: Thu, 03 Sep 2020 02:33:50 -0000
User-agent: mu4e 1.5.5; emacs 28.0.50

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.
;;; FIXME
(let ((emacs-processes
       (length (mapcar
                'string-to-number
                (seq-filter
                 (lambda (str)
                   (not (string-empty-p str)))
                 (split-string
                  ;; (shell-command-to-string "ps -C emacs -o pid=")
                  (shell-command-to-string "ps -C emacs -o pid=")
                  "\n"))))))
  (when (<= emacs-processes 1)
    (message "init-emacs-session loading")
    (require 'init-emacs-session)))
#+end_src

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 which is in /usr/local/bin and
compiled from source code.

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

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3



reply via email to

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