From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.help Subject: Re: How to detect two emacs process in Elisp code? Date: Sat, 18 Jul 2020 08:25:23 -0400 Message-ID: References: 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="19431"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-help To: "numbchild@gmail.com" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 18 14:26: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 1jwlur-0004y2-US for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 14:26:09 +0200 Original-Received: from localhost ([::1]:46446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwluq-0004ti-Uj for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 18 Jul 2020 08:26:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwluQ-0004sW-Ij for help-gnu-emacs@gnu.org; Sat, 18 Jul 2020 08:25:42 -0400 Original-Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]:41713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwluP-0003cC-6d for help-gnu-emacs@gnu.org; Sat, 18 Jul 2020 08:25:42 -0400 Original-Received: by mail-oi1-x22e.google.com with SMTP id y22so10352161oie.8 for ; Sat, 18 Jul 2020 05:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KcWodcIbOYbQDwnL+xycdx7D8pi2KPWAmrQRVetbgaE=; b=BKOs7thLUwfUVvCs1XnWotEdOvRtlV+FH6PFK6XYsogrkBMXqovvHUrE1Cj00nqd+A 2f6hGQcAx/x7kwKGzRl0wSKbLN+IoOrpBmVNaH8Q0kBpwZZiMRzSV2gPoQOlXO9ATVax GHjYsEOrF39w6BrwLdIIViQf5P+/5tAfrkaiqNI75iGnZOa6Lh+gn0Iifbf6u6tdqo10 XiTJ2psJkvg2W9NcosD7pItnKdO4dDEerbVVk0OA/K6QeEZQuKv0r9UlIjuryUdvRmMe 9EVXTcOmtCAINgdFF6OHcF0UeShYzbKk2Gn2+QrWSuxa0mfdBsrqFUuI6hhd8QfkAXmJ T47A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KcWodcIbOYbQDwnL+xycdx7D8pi2KPWAmrQRVetbgaE=; b=BMC0M1xNurtH8vmxZLeJyn7EsLNH7/Tl3eixciqVXA0c2y6btnzPog8lz4dlxCSzGx bw6GCkWAzDA5wVhGZAG2HSlHFis0KIc5MsCSLqRD0y0myLnUX31XQ4Y7oroUVtLZJGES knmSjOgvYP+LbllOrbNR43xrMAxtoWMgnWDOPYqjmSvG1ujymeDlzXVk3Lb9PCS0skxU Vmzi+IETjmLiksfELVLVFfvpOR8+ULRWQAkDfaaTDpkAB7LFdzKrLg1gvHn87fP8xU3C OP3ZtktdkPFyNpfdJR27J/cruBPUG+8zUBZevUIqVwYFbKAnBOkSlbfv757r91XXXf/J 5WYw== X-Gm-Message-State: AOAM530X1e9Q46YiYlN8CVU2KTlxxX86X4WDv73IWOOBZSrZubtkioTm a4naWb6Ri7NZZAonNVFSg1N0IVF7UyFplVSm6a4= X-Google-Smtp-Source: ABdhPJzP5RXVuh5qIT2GzrnpR8Y0WaXeY3mK+dEmHMlwFNfaA/rxmLvhNJiZRaRXbccVnyM7TZE5/vFJKgzzCSRK6pk= X-Received: by 2002:a05:6808:8c4:: with SMTP id k4mr11525345oij.177.1595075139763; Sat, 18 Jul 2020 05:25:39 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=npostavs@gmail.com; helo=mail-oi1-x22e.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: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, 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:123556 Archived-At: On Sat, 18 Jul 2020 at 01:56, numbchild@gmail.com wrote: > (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. If your init does (server-start), then you can just check for (server-running-p). Otherwise, something like (seq-count (lambda (proc) (and (equal (alist-get 'user proc) user-login-name) (string-match "\\" (alist-get 'comm proc)))) (mapcar #'process-attributes (list-system-processes)))