From: Rick Sladkey (jrs@world.std.com)
Date: 04/07/93


From: jrs@world.std.com (Rick Sladkey)
Subject: Re: There's a little glitch in the binary of emacs in SLS
Date: Thu, 8 Apr 1993 02:39:07 GMT


>>>>> On 8 Apr 93 00:49:16 GMT, krej@electrum.kth.se (Kristian Ejvind) said:

Kristian> I've got SLS with 99pl6 (I fetched it 5/4). Evaluating
Kristian> (load-average)
Kristian> gives me the error:
Kristian> load-average not implemented for this operating system
Kristian> which undoubtedly isn't true. (emacs-version) gives me "GNU Emacs
Kristian> 18.59.1 of Thu nov 1992 on lepton (linux)" and emacs-build-time is
Kristian> "Thu Nov 12 00:03:05 1992"
Kristian> I assume something went wrong while compiling emacs for linux.

I didn't miss it because I never use `load-average' but it easy enough
to implement it using only Emacs Lisp because Linux has /proc.
=====
;;; Linux /proc-based load-average
;;; Rick Sladkey <jrs@world.std.com>

(defun load-average ()
  "This function returns the current 1 minute, 5 minute and 15
minute load averages in a list. The values are integers that
are 100 times the system load averages. (The load averages
indicate the number of processes trying to run.)"
  (save-excursion
    (set-buffer (get-buffer-create " *load-average*"))
    (erase-buffer)
    (insert "(")
    (let ((temp (make-temp-name "/tmp/la")))
      (unwind-protect
          (progn
            (copy-file "/proc/loadavg" temp t)
            (insert-file-contents temp))
        (delete-file temp)))
    (goto-char (point-max))
    (insert ")")
    (goto-char (point-min))
    (while (search-forward "." nil t) (delete-char -1))
    (goto-char (point-min))
    (read (current-buffer))))