From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "numbchild@gmail.com" Newsgroups: gmane.emacs.help Subject: How to detect two emacs process in Elisp code? Date: Sat, 18 Jul 2020 13:55:49 +0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38817"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 18 07:56:43 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jwfpy-0009zk-SU for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 07:56:42 +0200 Original-Received: from localhost ([::1]:51618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwfpx-0007z7-V8 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 01:56:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwfpb-0007ym-7c for help-gnu-emacs@gnu.org; Sat, 18 Jul 2020 01:56:19 -0400 Original-Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]:46351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwfpZ-0000jl-BW for help-gnu-emacs@gnu.org; Sat, 18 Jul 2020 01:56:18 -0400 Original-Received: by mail-ua1-x932.google.com with SMTP id k7so3506766uan.13 for ; Fri, 17 Jul 2020 22:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=q8P0MO82li0ljEvBCjOiimMdl+PyVVH5r4yNyefXWRU=; b=tPwGiEgxcIq3+LcTrSK3DW2X47g1zTNwq0L4TcJ4oOk6k+KReHcDCF34kaUV54dlqR +Ib5ltGCOXfqIEhy4/Yf8unLO0TnoMO9OuLAc06IXHyW75UZRvZL7OwhSAlS7e/lqIHT UrPrw1nZKqf9WGF1WNb4FIQ8B1kzWfioOPOt0t/rsamVJO8/OJBXP8NCfHJpsXYWp3Pn hGNczKyJcUytp69yQBwRYxpoTK/OQKdnLCGdqvmbliadNqFOwru6T5Q/nYek5mtHEVUW O6zgGjUYV/vhq85EMuS+ZIEf1njt4BZ8kDClZNwIcsjsaPV2/jy1wEeCbvzgRUUMkac6 L/LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=q8P0MO82li0ljEvBCjOiimMdl+PyVVH5r4yNyefXWRU=; b=WESU7wGSShS7dD8O7xGjI6NkGFhElDSW5qarqvojI6C3zWyMhJ55eNW1RI4GWHUh3x +qu+YJ/iPy/71SNN0Lx0NGMk8u9II7TRhmujKLC8ZQthBOWfEBep/2ybzlYUQJQqC6w9 kXBG0+tH4ZX0nwQNYXdPbAbz/CtG+mDbkb+n9qItnTrgb1BDo7iFfIL1N9Ge3NYSMnuc ObVpFcDfRk65vhJAjnmR6MzbDXjwgnD3dL2SUQe4D91d/Nyi39x0mvh5rIBC1MB5yIg7 IPnkKtBg6JeryNcIo6DK0aSJViIT7rT7xpD4r+uhiSe8uQTvuSjY3WIZHtI0kVL7Q3M6 nBnw== X-Gm-Message-State: AOAM532KwTuSjT4LVNqerXt8pMJ7bMTN5zvHNq7QIUL2gCIJwRpipYqH 7gfoxZf8dl7Y3HOfDMr05xJPGjfYE/lq2GQDb2q9owVZk2m7 X-Google-Smtp-Source: ABdhPJw3mSWQRY6tMmrruG69pq5JNT1MdQZnNlr5aRGJdVr4L0YC28j8wyQjxjYLK17Hx6XGIA3tAz2KJiQK/8oASCw= X-Received: by 2002:ab0:7182:: with SMTP id l2mr9806122uao.13.1595051776101; Fri, 17 Jul 2020 22:56:16 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::932; envelope-from=numbchild@gmail.com; helo=mail-ua1-x932.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:123555 Archived-At: 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 in /usr/local/bin and compiled from source code. Does anyone has good solution for this? Thanks in advance. [stardiviner] GPG key ID: 47C32433 IRC(freeenode): stardiviner Twitter: @numbchild Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 Blog: http://stardiviner.github.io/