Skip to content

Commit 30d832a

Browse files
author
Ammon Smith
committed
Add getloadavg.c
1 parent b934a0e commit 30d832a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/getloadavg.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#define _DEFAULT_SOURCE
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
6+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
7+
#define UNUSED(x) ((void)(x))
8+
9+
int main(int argc, char *argv[])
10+
{
11+
double up[3];
12+
13+
UNUSED(argc);
14+
UNUSED(argv);
15+
16+
if (getloadavg(up, ARRAY_SIZE(up)) < 0) {
17+
fprintf(stderr, "%s: getloadavg() failed\n", argv[0]);
18+
return 1;
19+
}
20+
21+
printf("%.2f %.2f %.2f\n", up[0], up[1], up[2]);
22+
return 0;
23+
}

0 commit comments

Comments
 (0)