diff --git a/apps/src/uptime.c b/apps/src/uptime.c index ee6313d5..4a5a652e 100644 --- a/apps/src/uptime.c +++ b/apps/src/uptime.c @@ -1,27 +1,10 @@ #include -#include +#include int main() { - FILE* fp = fopen("/dev/uptime", "r"); - if (!fp) - { - perror("fopen"); - return 1; - } + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); // On Luna, CLOCK_MONOTONIC starts at boot. - char buf[BUFSIZ]; - fgets(buf, sizeof(buf), fp); - - if (ferror(fp)) - { - perror("fgets"); - return 1; - } - - long ms_uptime = atol(buf); - - printf("up for %ld seconds\n", ms_uptime / 1000); - - fclose(fp); + printf("up for %ld seconds\n", tp.tv_sec); } \ No newline at end of file