From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.devel Subject: process-attributes-ps-args / process-attributes-ps-format for Darwin Date: Tue, 12 Apr 2022 03:42:32 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5215"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Cc: emacs-devel@gnu.org To: michael.albinus@gmx.de Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Apr 12 03:07:00 2022 Return-path: Envelope-to: ged-emacs-devel@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 1ne4zh-00017I-49 for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Apr 2022 03:06:58 +0200 Original-Received: from localhost ([::1]:58636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ne4zg-0002dz-7X for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Apr 2022 21:06:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ne4cA-00073Q-Tl for emacs-devel@gnu.org; Mon, 11 Apr 2022 20:42:38 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:43895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ne4c9-0003Hj-1U for emacs-devel@gnu.org; Mon, 11 Apr 2022 20:42:38 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A8E425C0217; Mon, 11 Apr 2022 20:42:34 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 11 Apr 2022 20:42:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1649724154; x=1649810554; bh=aMB7YjiKnEEmPFOMauQ4UHa+Q+7am+lA1qE +TTdHuhs=; b=nOjrvF8HtbZHTgnzdnSvlN3Oo1KLgIrLPNaYShniWfTh19A0pNY HlFnBe78AuLm+xqMSYRlG4ckJ3tWf9UkSEBv3MrEvAM+fDmrOdTp2j9WI+M645gc Sd8I7c6x4amnLxwh7Nvew9l4afWiuyzUSC6xelseXx13UsX/cQbj5cvjFLa4WY9P 5kULKWCV4eqoPO+fipUQXH1LZQGsKcV8IaBzcs8N6Th+0d2ukujtV+HDrZ1/H0lu uijl5hf/xRmd/lnZAhJt7z0WmRZjWht+TOcbANXTlvMj7AsCRP7DYmrb9/mg1COw eSa1Xz/tFzXYVdsXG5TMFrV2W4PjwU/Lj6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1649724154; x=1649810554; bh=aMB7YjiKnEEmP FOMauQ4UHa+Q+7am+lA1qE+TTdHuhs=; b=XrGhjkczyP5oalU3vowkBCXk9cHHV nwEyMAvJRxXeoph2kQAIEqXgGvFnu+WNwUnM1rh723qjE21AB6ysnoInoigUTfzu M/X0CeHHMB8s0WZcvUcjaJxDtCk0eHfpuVuQz3n/2eR1OQC23AVgCEkqokPuFfG8 y8EwAPW8lr0B9E8w/3Ni6kGocIa3Fg5eyU8tBTaeKQEOXLyD04sD59htgkJQcyiK RgS052QkxehG1zZ/ZGM1FhqL85ulYYT4Zh15c8KieQ+okkpFvPglKOyJ2lEBgqBl 5v8ofiZWlWC+e0e/oFfximXEC1SRhCgBlDlUdemSaqlbLKCPt7FWPwM8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekjedgfeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufgffkfggtgesthdtredttd ertdenucfhrhhomhephfhilhhiphhpucfiuhhnsghinhcuoehfghhunhgsihhnsehfrghs thhmrghilhdrfhhmqeenucggtffrrghtthgvrhhnpeetkefggfejudejkeevheduteffud ffjeeutdevveefueevgfeiieeuueelkeduudenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehfghhunhgsihhnsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Apr 2022 20:42:33 -0400 (EDT) Mail-Followup-To: michael.albinus@gmx.de, emacs-devel@gnu.org Received-SPF: pass client-ip=66.111.4.29; envelope-from=fgunbin@fastmail.fm; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:288258 Archived-At: Hello Michael, Here's the patch for Darwin. Also I've added a piece of code to automatically set profile for local sudo case, so the users on macOS don't see the empty list in Proced by default. Strangely, ps on macOS doesn't have keyword to output group name, so I've omitted it. Thanks, Filipp diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index 81990c6a33..901826bfc1 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el @@ -430,6 +430,100 @@ tramp-connection-local-busybox-ps-variables 'tramp-connection-local-busybox-ps-profile tramp-connection-local-busybox-ps-variables) + +;; Darwin (macOS) +(defconst tramp-darwin-process-attributes-ps-args + `("-acxww" + "-o" + ,(mapconcat + #'identity + '("pid" + "uid" + "user" + "gid" + "comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + ",") + "-o" "state=abcde" + "-o" + ,(mapconcat + #'identity + '("ppid" + "pgid" + "sess" + "tty" + "tpgid" + "minflt" + "majflt" + "time" + "pri" + "nice" + "vsz" + "rss" + "etime" + "pcpu" + "pmem" + "args") + ",")) + "List of arguments for \"ps\". +See `tramp-process-attributes-ps-args'.") + +(defconst tramp-darwin-process-attributes-ps-format + '((pid . number) + (euid . number) + (user . string) + (egid . number) + (comm . 52) + (state . 5) + (ppid . number) + (pgrp . number) + (sess . number) + (ttname . string) + (tpgid . number) + (minflt . number) + (majflt . number) + (time . tramp-ps-time) + (pri . number) + (nice . number) + (vsize . number) + (rss . number) + (etime . tramp-ps-time) + (pcpu . number) + (pmem . number) + (args . nil)) + "Alist of formats for \"ps\". +See `tramp-process-attributes-ps-format'.") + +(defconst tramp-connection-local-darwin-ps-variables + `((tramp-process-attributes-ps-args + . ,tramp-darwin-process-attributes-ps-args) + (tramp-process-attributes-ps-format + . ,tramp-darwin-process-attributes-ps-format)) + "Default connection-local ps variables for remote Darwin +connections.") + +(connection-local-set-profile-variables + 'tramp-connection-local-darwin-ps-profile + tramp-connection-local-darwin-ps-variables) + + + +;; Preset default "ps" profile for the case of local sudo, based on +;; system type. + +(let ((local-sudo-profile + (cond ((eq system-type 'darwin) + 'tramp-connection-local-darwin-ps-profile) + ;; ...add other system types here + ))) + (when local-sudo-profile + (connection-local-set-profiles + `(:application tramp :protocol "sudo" :user "root" :machine ,(system-name)) + local-sudo-profile) + (connection-local-set-profiles + '(:application tramp :protocol "sudo" :user "root" :machine "localhost") + local-sudo-profile))) + + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-integration 'force)))