summaryrefslogtreecommitdiff
path: root/linux/uptime.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/uptime.c')
-rw-r--r--linux/uptime.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/linux/uptime.c b/linux/uptime.c
new file mode 100644
index 00000000..d6e6c9d5
--- /dev/null
+++ b/linux/uptime.c
@@ -0,0 +1,12 @@
+#include <sys/sysinfo.h>
+
+long uptime(void) {
+ struct sysinfo si;
+
+ if (sysinfo(&si) != 0)
+ {
+ return -1;
+ }
+
+ return si.uptime;
+}