Initial revision

git-svn-id: file:///srv/svn/joey/bsdgames-trunk@5086 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
1999-09-08 23:56:51 +00:00
commit 03272d67da
623 changed files with 243457 additions and 0 deletions

26
lib/getloadavg.c Normal file
View File

@@ -0,0 +1,26 @@
/* getloadavg.c - bsd-games implementation of getloadavg */
#include <stdio.h>
#include <stdlib.h>
int
getloadavg(double loadavg[], int nelem)
{
double load_averages[3];
FILE *fp;
int count;
int i;
int nc;
fp = fopen("/proc/loadavg", "r");
if (fp == NULL)
return -1;
count = fscanf(fp, "%lf%lf%lf", &(load_averages[0]), &(load_averages[1]),
&(load_averages[2]));
fclose(fp);
if ((count == EOF) || (count == 0))
return -1;
nc = ((nelem < count) ? nelem : count);
for (i = 0; i < nc; i++)
loadavg[i] = load_averages[i];
return nc;
}