Function: tramp-get-process-attributes

tramp-get-process-attributes is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-get-process-attributes VEC)

Documentation

Return all process attributes for connection VEC.

Parsing the remote "ps" output is controlled by tramp-process-attributes-ps-args and tramp-process-attributes-ps-format.

It is not guaranteed, that all process attributes as described in process-attributes are returned. The additional attribute pid shall be returned always.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-get-process-attributes (vec)
  "Return all process attributes for connection VEC.
Parsing the remote \"ps\" output is controlled by
`tramp-process-attributes-ps-args' and
`tramp-process-attributes-ps-format'.

It is not guaranteed, that all process attributes as described in
`process-attributes' are returned.  The additional attribute
`pid' shall be returned always."
  (with-tramp-file-property vec "/" "process-attributes"
    (ignore-errors
      (with-temp-buffer
        (hack-connection-local-variables-apply
         (connection-local-criteria-for-default-directory))
        ;; (pop-to-buffer (current-buffer))
        (when (zerop
               (apply
                #'process-file "ps" nil t nil tramp-process-attributes-ps-args))
          (let (result res)
            (goto-char (point-min))
            (while (not (eobp))
              ;; (tramp-test-message
              ;;  "%s" (buffer-substring (point) (line-end-position)))
              (when (save-excursion
                      (search-forward-regexp
		       (rx digit) (line-end-position) 'noerror))
                (setq res nil)
                (dolist (elt tramp-process-attributes-ps-format)
                  (push
                   (cons
                    (car elt)
                    (cond
                     ((eq (cdr elt) 'number) (read (current-buffer)))
                     ((eq (cdr elt) 'string)
                      (search-forward-regexp (rx (+ (not blank))))
                      (match-string 0))
                     ((numberp (cdr elt))
                      (search-forward-regexp (rx (+ blank)))
                      (search-forward-regexp (rx (+ nonl)) (+ (point) (cdr elt)))
                      (string-trim (match-string 0)))
                     ((fboundp (cdr elt))
                      (funcall (cdr elt)))
                     ((null (cdr elt))
                      (search-forward-regexp (rx (+ blank)))
                      (buffer-substring (point) (line-end-position)))))
                   res))
                ;; `nice' could be `-'.
                (setq res (rassq-delete-all '- res))
                (push (append res) result))
              (forward-line))
            ;; Return result.
            result))))))