PROCPS_UPTIME(3)

NAME
procps_uptime, procps_sprint, procps_uptime_sprint_short - provide the uptime and idle time in seconds

SYNOPSIS
#include <proc/procps.h>

int procps_uptime(double * uptime_secs, double * idle_secs);
char *procps_uptime_sprint(void);
char *procps_uptime_sprint_short(void);

Link with -lprocps.

DESCRIPTION
procps_uptime() returns the uptime and idle time of the system. Either the uptime_secs or idle_secs can be NULL in which case that variable will not be returned. The sprint variety of the functions return a human-readable string of the uptime and other statistics.

RETURN VALUE
procps_uptime() returns 0 on success. On failure, it returns a negative integer to one of the values defined below.

-ERANGE
    Unable to parse the uptime file.

procps_uptime() may also return any (negated) value that fopen() may set errno to. procps_uptime_sprint_short() return a string from a statically allocated buffer which displays uptime. procps_uptime_sprint() also displays users and load average in the buffer. The formats are the same as uptime(1) with and without the -p option.

FILES

/proc/uptime
    The raw values for uptime and idle time.

VERSIONS
procps_uptime() first appeared in libproc-2 version 0.0.

SEE ALSO
uptime(1), fopen(3), proc(5).