apéro de samedi midi en route...

This commit is contained in:
tTh
2018-12-08 13:02:24 +01:00
parent 44befe2867
commit 2576b84d57
6 changed files with 55 additions and 5 deletions

13
funcs.c
View File

@@ -48,18 +48,25 @@ return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
/* --------------------------------------------------------------- */
double get_loadavg(int foo)
int get_loadavg(double *where)
{
FILE *fp;
double loads[3];
int foo;
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
perror("read loadavg");
return -42.51;
return -1;
}
foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2);
if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo);
memcpy(where, loads, 3 * sizeof(double));
fclose(fp);
return -42.51;
return 0;
}
/* --------------------------------------------------------------- */