Function: proced-tree

proced-tree is a byte-compiled function defined in proced.el.gz.

Signature

(proced-tree PROCESS-ALIST)

Documentation

Rearrange PROCESS-ALIST as process tree.

If proced-tree-flag is non-nil, rearrange PROCESS-ALIST such that every processes is followed by its child processes. Each process gets a tree attribute that specifies the depth of the process in the tree. A root process is a process with no parent within PROCESS-ALIST according to its value of the ppid attribute. It has depth 0.

If proced-tree-flag is nil, remove the tree attribute. Return the rearranged process list.

Source Code

;; Defined in /usr/src/emacs/lisp/proced.el.gz
(defun proced-tree (process-alist)
  "Rearrange PROCESS-ALIST as process tree.
If `proced-tree-flag' is non-nil, rearrange PROCESS-ALIST such that
every processes is followed by its child processes.  Each process
gets a tree attribute that specifies the depth of the process in the tree.
A root process is a process with no parent within PROCESS-ALIST according
to its value of the ppid attribute.  It has depth 0.

If `proced-tree-flag' is nil, remove the tree attribute.
Return the rearranged process list."
  (if proced-tree-flag
      ;; add tree attribute
      (let ((process-tree (proced-process-tree process-alist))
            (proced-tree-depth 0)
            (proced-temp-alist process-alist)
            proced-process-tree pt)
        (while (setq pt (pop process-tree))
          (proced-tree-insert pt))
        (nreverse proced-process-tree))
    ;; remove tree attribute
    (let ((process-alist process-alist))
      (while process-alist
        (setcar process-alist
                (assq-delete-all 'tree (car process-alist)))
        (pop process-alist)))
    process-alist))