projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
implement hcreate_r, hdestroy_r and hsearch_r
[oweals/musl.git]
/
src
/
legacy
/
getloadavg.c
1
#define _GNU_SOURCE
2
#include <stdlib.h>
3
#include <stdio.h>
4
#include <string.h>
5
6
int getloadavg(double *a, int n)
7
{
8
int i;
9
double b[3];
10
FILE *f = fopen("/proc/loadavg", "rbe");
11
if (!f) return -1;
12
i = fscanf(f, "%lf %lf %lf", b, b+1, b+2);
13
fclose(f);
14
if (n > i) n = i;
15
if (n < 0) return -1;
16
memcpy(a, b, n * sizeof *a);
17
return n;
18
}