mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
340 B
18 lines
340 B
#define _GNU_SOURCE
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int getloadavg(double *a, int n)
|
|
{
|
|
int i;
|
|
double b[3];
|
|
FILE *f = fopen("/proc/loadavg", "rbe");
|
|
if (!f) return -1;
|
|
i = fscanf(f, "%lf %lf %lf", b, b+1, b+2);
|
|
fclose(f);
|
|
if (n > i) n = i;
|
|
if (n < 0) return -1;
|
|
memcpy(a, b, n * sizeof *a);
|
|
return n;
|
|
}
|
|
|