Check getloadavg() return value and call the function directly
on the glibtop_loadavg buffer member.
This commit is contained in:
@@ -48,22 +48,17 @@ _glibtop_init_loadavg_s (glibtop *server)
|
||||
void
|
||||
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
|
||||
{
|
||||
double ldavg[3];
|
||||
pid_t last_pid;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_loadavg));
|
||||
|
||||
getloadavg (ldavg, 3);
|
||||
if (getloadavg (buf->loadavg, G_N_ELEMENTS(buf->loadavg)) == -1)
|
||||
return;
|
||||
|
||||
/* fill in the struct */
|
||||
buf->flags = _glibtop_sysdeps_loadavg;
|
||||
for (i = 0; i < 3; i++) {
|
||||
buf->loadavg [i] = ldavg [i];
|
||||
} /* end for */
|
||||
|
||||
len = sizeof (last_pid);
|
||||
if (sysctlbyname ("kern.lastpid", &last_pid, &len, NULL, 0)) {
|
||||
|
Reference in New Issue
Block a user