unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* process-attributes-ps-args / process-attributes-ps-format for Darwin
@ 2022-04-12  0:42 Filipp Gunbin
  2022-04-12  7:46 ` Michael Albinus
  0 siblings, 1 reply; 3+ messages in thread
From: Filipp Gunbin @ 2022-04-12  0:42 UTC (permalink / raw)
  To: michael.albinus; +Cc: emacs-devel

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)
 
+\f
+;; 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)
+
+
+\f
+;; 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)))
 



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: process-attributes-ps-args / process-attributes-ps-format for Darwin
  2022-04-12  0:42 process-attributes-ps-args / process-attributes-ps-format for Darwin Filipp Gunbin
@ 2022-04-12  7:46 ` Michael Albinus
  2022-04-12 16:41   ` Filipp Gunbin
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Albinus @ 2022-04-12  7:46 UTC (permalink / raw)
  To: emacs-devel

Filipp Gunbin <fgunbin@fastmail.fm> writes:

> Hello Michael,

Hi Filipp,

> Here's the patch for Darwin.

Thanks for this, I've applied it in your name.

> 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.

Yep. I've adapted it a little bit; there's no need to discriminate for
"sudo" profile and "root" user. The ps command shall behave similar for
everybody on a macOS machine.

> Strangely, ps on macOS doesn't have keyword to output group name, so
> I've omitted it.

Some attributes are also missing for other systems. I believe, the most
important attributes we need are `pid', `comm', and `state'.

> Thanks,
> Filipp

Best regards, Michael.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: process-attributes-ps-args / process-attributes-ps-format for Darwin
  2022-04-12  7:46 ` Michael Albinus
@ 2022-04-12 16:41   ` Filipp Gunbin
  0 siblings, 0 replies; 3+ messages in thread
From: Filipp Gunbin @ 2022-04-12 16:41 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

On 12/04/2022 09:46 +0200, Michael Albinus wrote:

> Filipp Gunbin <fgunbin@fastmail.fm> writes:
>
>> Hello Michael,
>
> Hi Filipp,
>
>> Here's the patch for Darwin.
>
> Thanks for this, I've applied it in your name.
>
>> 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.
>
> Yep. I've adapted it a little bit; there's no need to discriminate for
> "sudo" profile and "root" user. The ps command shall behave similar for
> everybody on a macOS machine.
>
>> Strangely, ps on macOS doesn't have keyword to output group name, so
>> I've omitted it.
>
> Some attributes are also missing for other systems. I believe, the most
> important attributes we need are `pid', `comm', and `state'.
>
>> Thanks,
>> Filipp
>
> Best regards, Michael.

Great, thank you!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-12 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  0:42 process-attributes-ps-args / process-attributes-ps-format for Darwin Filipp Gunbin
2022-04-12  7:46 ` Michael Albinus
2022-04-12 16:41   ` Filipp Gunbin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).