From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: stardiviner Newsgroups: gmane.emacs.help Subject: How to detect two emacs process in Elisp code? Date: Fri, 17 Jul 2020 22:54:50 +0800 Message-ID: <87ft9s283t.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40082"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.5; emacs 28.0.50 To: Emacs Help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 03 04:34:10 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 1kDf4j-000AJr-Vy for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 03 Sep 2020 04:34:09 +0200 Original-Received: from localhost ([::1]:50086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDf4i-0001Yq-P8 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 02 Sep 2020 22:34:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDf4Q-0001Yi-LK for help-gnu-emacs@gnu.org; Wed, 02 Sep 2020 22:33:50 -0400 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:45362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDf4P-0001CU-1y for help-gnu-emacs@gnu.org; Wed, 02 Sep 2020 22:33:50 -0400 Original-Received: by mail-pf1-x42c.google.com with SMTP id k15so966796pfc.12 for ; Wed, 02 Sep 2020 19:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:reply-to:date:mime-version; bh=lFajEVVPRGu5ebdb/98zgShtPKYijI+Cm2mnrL9/pWc=; b=LaYN0FvSgYTVDtGip7iZy/zSxKTIlP48RljX51h3cuynjS23YLvQ7H198YaE784K+a abvxce+JBkpRjoNu0AOonmL2hmrHZgPoDyOleOUyKTxSembpzp2tXtqRldHU8EwGRPEa ThgO4oRs6zt27gk8as7405quIJnnjywbAuu9a8hn7xD3aqdQkA6tfypYCBWtD3jpgHTC nVFxuhMRAVOkf0Ory7mdWlT8fsLbbtPHaeiqANbw3mbQFamUTaM7ByKK0TC6iLYdcpJ7 SBIMw4VOywH8BtBVO+JX6LGHEn8ZO+or5B+QsBoEq257nAKCeeVKB1PbK8bZuhnAiGiC JCtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:reply-to :date:mime-version; bh=lFajEVVPRGu5ebdb/98zgShtPKYijI+Cm2mnrL9/pWc=; b=RgUe8RJRfdRuhQ72OYLy/vVzfnM16tTO3CnN39L/O1K031gVf3co5ijGemu9OHH6/B 5uM/ZgLGErmOZ8Zw7TTnpEaDynbeY05pV7PisfVgI+uh5IMDND1zTb+hWUmDR8zrfo+L /n/DxI0BrehndajSbp4uU/8GJTTVB38Pfgy47YYMrq5l1IowwGJfwLCVlxwBKw0wrKMJ HC5hKoA553BqscBITHyQ4W/+9t/H861l+EiqRlph7LKni0y5yLN10jS36Dm5EEP/ohgU 1LrRaxauBRBsKuxGa/sNMpz9j1jYkej/jt9j2nGEOY3UMbX9xqD2mWQYiN1/uH66V+fA HB3Q== X-Gm-Message-State: AOAM5339Gqe8RX8Y3Z2RNwqsUX4sq03YdlSe9oKKFx58QcjuIdcB4P90 zKRulEQwDsxulNZtjKNleMCk3SmElG4F X-Google-Smtp-Source: ABdhPJxKmhKVZ7a4NrSd+Kq14hwOo8KzzAxHH2rcg4+J8sAiuDdE10id0PaEVdW8z1kOkq4Z9UjpIQ== X-Received: by 2002:a17:902:a715:b029:d0:89f3:28cf with SMTP id w21-20020a170902a715b02900d089f328cfmr422376plq.11.1599100426729; Wed, 02 Sep 2020 19:33:46 -0700 (PDT) Original-Received: from dark.gmail.com ([183.246.146.178]) by smtp.gmail.com with ESMTPSA id e12sm653755pjd.55.2020.09.02.19.33.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 19:33:46 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=numbchild@gmail.com; helo=mail-pf1-x42c.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: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:123911 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 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