Now that the library correctly returns an error if loadavg
is not available, tload can tell the user the bad news.
References:
procps-ng/procps#227
commit
8fcd14de18b998647ba47f5b35feb1d85e2d2f08
Signed-off-by: Craig Small <csmall@dropbear.xyz>
alrm(0);
while (1) {
+ int rc;
if (scale_fact < max_scale)
scale_fact *= 2.0; /* help it drift back up. */
- procps_loadavg(&av[0], &av[1], &av[2]);
+ if ((rc = procps_loadavg(&av[0], &av[1], &av[2])) < 0)
+ {
+ if (rc == -ENOENT)
+ xerrx(EXIT_FAILURE,
+ _("Load average file /proc/loadavg does not exist"));
+ else
+ xerrx(EXIT_FAILURE,
+ _("Unable to get load average"));
+ }
do {
lines = av[0] * scale_fact;