@vindex tramp-connection-local-bsd-ps-variables
@vindex tramp-connection-local-busybox-ps-profile
@vindex tramp-connection-local-busybox-ps-variables
+@vindex tramp-connection-local-darwin-ps-profile
+@vindex tramp-connection-local-darwin-ps-variables
The default values for @code{tramp-process-attributes-ps-args} and
@code{tramp-process-attributes-ps-format} can be overwritten by
connection-local variables.
@code{tramp-adb-connection-local-default-ps-profile} and
@code{tramp-adb-connection-local-default-ps-variables}.
-There are two further predefined sets of connection-local variables
-for remote BSD systems, and for a remote @command{ps} command
-implemented with @command{busybox}. These are called
-@code{tramp-connection-local-bsd-ps-profile},
-@code{tramp-connection-local-bsd-ps-variables},
-@code{tramp-connection-local-busybox-ps-profile}, and
-@code{tramp-connection-local-busybox-ps-variables}. Use them
-like
+There are three further predefined sets of connection-local variables
+for remote BSD systems, for remote macOS systems, and for a remote
+@command{ps} command implemented with @command{busybox}. These are
+called @code{tramp-connection-local-*-ps-profile} and
+@code{tramp-connection-local-*-ps-variables}. Use them like
@lisp
@group
'tramp-connection-local-busybox-ps-profile
tramp-connection-local-busybox-ps-variables)
-\f
-;; Darwin (macOS)
+;; Darwin (macOS).
(defconst tramp-darwin-process-attributes-ps-args
`("-acxww"
"-o"
. ,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.")
+ "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 local hosts, based on system type.
-\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)))
-
+(when-let ((local-profile
+ (cond ((eq system-type 'darwin)
+ 'tramp-connection-local-darwin-ps-profile)
+ ;; ... Add other system types here.
+ )))
+ (connection-local-set-profiles
+ `(:application tramp :machine ,(system-name))
+ local-profile)
+ (connection-local-set-profiles
+ '(:application tramp :machine "localhost")
+ local-profile))
(add-hook 'tramp-unload-hook
(lambda () (unload-feature 'tramp-integration 'force)))
(ignore-errors (kill-process proc))
(ignore-errors (delete-process proc))))))
+(ert-deftest tramp-test31-list-system-processes ()
+ "Check `list-system-processes'."
+ :tags '(:expensive-test)
+ (skip-unless (tramp--test-enabled))
+ (skip-unless (tramp--test-supports-processes-p))
+ ;; `list-system-processes' is supported since Emacs 29.1.
+ (skip-unless (tramp--test-emacs29-p))
+
+ (let ((default-directory tramp-test-temporary-file-directory))
+ (skip-unless (consp (list-system-processes)))
+ (should (not (equal (list-system-processes)
+ (let ((default-directory temporary-file-directory))
+ (list-system-processes)))))))
+
+(ert-deftest tramp-test31-process-attributes ()
+ "Check `process-attributes'."
+ :tags '(:expensive-test :tramp-asynchronous-processes)
+ (skip-unless (tramp--test-enabled))
+ (skip-unless (tramp--test-supports-processes-p))
+ ;; `process-attributes' is supported since Emacs 29.1.
+ (skip-unless (tramp--test-emacs29-p))
+
+ ;; We must use `file-truename' for the temporary directory, in
+ ;; order to establish the connection prior running an asynchronous
+ ;; process.
+ (let ((default-directory (file-truename tramp-test-temporary-file-directory))
+ (delete-exited-processes t)
+ kill-buffer-query-functions command proc)
+ (skip-unless (consp (list-system-processes)))
+
+ (unwind-protect
+ (progn
+ (setq command '("sleep" "100")
+ proc (apply #'start-file-process "test" nil command))
+ (while (accept-process-output proc 0))
+ (when-let ((pid (process-get proc 'remote-pid))
+ (attributes (process-attributes pid)))
+ ;; (tramp--test-message "%s" attributes)
+ (should (equal (cdr (assq 'comm attributes)) (car command)))
+ (should (equal (cdr (assq 'args attributes))
+ (mapconcat #'identity command " ")))))
+
+ ;; Cleanup.
+ (ignore-errors (delete-process proc)))))
+
(defun tramp--test-async-shell-command
(command output-buffer &optional error-buffer input)
"Like `async-shell-command', reading the output.