summaryrefslogtreecommitdiff
path: root/lisp/proced.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2008-11-20 02:43:29 +0000
committerGlenn Morris <rgm@gnu.org>2008-11-20 02:43:29 +0000
commit76b4a8b1dfa2061eb8b4f816ccbbd6a08c87b254 (patch)
treed06309ad680b3fea29e287a7093e6065d2db0ef7 /lisp/proced.el
parent1bff871e0be701e538c02bdf19a5d8afca185f25 (diff)
downloademacs-76b4a8b1dfa2061eb8b4f816ccbbd6a08c87b254.tar.gz
(proced-available): New variable.
(proced-process-attributes): Move availability check from previous change from here... (proced): ... to here.
Diffstat (limited to 'lisp/proced.el')
-rw-r--r--lisp/proced.el47
1 files changed, 25 insertions, 22 deletions
diff --git a/lisp/proced.el b/lisp/proced.el
index dcb60e361f8..85980c8e311 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -574,6 +574,9 @@ are defined in `proced-grammar-alist'.
(setq proced-timer
(run-at-time t proced-timer-interval 'proced-timer))))
+(defvar proced-available nil
+ "Non-nil means Proced is known to work on this system.")
+
;; Proced mode is suitable only for specially formatted data.
(put 'proced-mode 'mode-class 'special)
@@ -585,6 +588,9 @@ information will be displayed but not selected.
See `proced-mode' for a description of features available in Proced buffers."
(interactive "P")
+ (or proced-available
+ (setq proced-available (not (null (list-system-processes))))
+ (error "Proced is not available on this system"))
(let ((buffer (get-buffer-create "*Proced*")) new)
(set-buffer buffer)
(setq new (zerop (buffer-size)))
@@ -1233,28 +1239,25 @@ With prefix REVERT non-nil revert listing."
(defun proced-process-attributes ()
"Return alist of attributes for each system process.
This alist can be customized via `proced-custom-attributes'."
- (let ((procs (list-system-processes)))
- (if procs
- (mapcar (lambda (pid)
- (let* ((attributes (system-process-attributes pid))
- (utime (cdr (assq 'utime attributes)))
- (stime (cdr (assq 'stime attributes)))
- (cutime (cdr (assq 'cutime attributes)))
- (cstime (cdr (assq 'cstime attributes)))
- attr)
- (setq attributes
- (append (list (cons 'pid pid))
- (if (and utime stime)
- (list (cons 'time (time-add utime stime))))
- (if (and cutime cstime)
- (list (cons 'ctime (time-add cutime cstime))))
- attributes))
- (dolist (fun proced-custom-attributes)
- (if (setq attr (funcall fun attributes))
- (push attr attributes)))
- (cons pid attributes)))
- procs)
- (error "Proced is not available on this system"))))
+ (mapcar (lambda (pid)
+ (let* ((attributes (system-process-attributes pid))
+ (utime (cdr (assq 'utime attributes)))
+ (stime (cdr (assq 'stime attributes)))
+ (cutime (cdr (assq 'cutime attributes)))
+ (cstime (cdr (assq 'cstime attributes)))
+ attr)
+ (setq attributes
+ (append (list (cons 'pid pid))
+ (if (and utime stime)
+ (list (cons 'time (time-add utime stime))))
+ (if (and cutime cstime)
+ (list (cons 'ctime (time-add cutime cstime))))
+ attributes))
+ (dolist (fun proced-custom-attributes)
+ (if (setq attr (funcall fun attributes))
+ (push attr attributes)))
+ (cons pid attributes)))
+ (list-system-processes)))
(defun proced-update (&optional revert quiet)
"Update the `proced' process information. Preserves point and marks.