uptime in seconds

Isn’t there any simple way of getting the systems uptime in seconds,
perhaps from a perl script ?

Jakob Bindslet <jagoop@image.dk> wrote:

Isn’t there any simple way of getting the systems uptime in seconds,
perhaps from a perl script ?

You could look at the start_time of procnto, the process
manager.

#include <libc.h>
#include <sys/debug.h>
#include <sys/procfs.h>

#define NANO 1000000000L

int show_uptime(void)
{
procfs_info info;
int fd, err;

if ( (fd = open( “/proc/1/as”, O_RDONLY )) == -1 )
return -1;

if ( (err = devctl( fd, DCMD_PROC_INFO, &info, sizeof(info), 0)) != EOK ) {
errno = err;
return -1;
}
return time(NULL) - (info.start_time/NANO);
}


cburgess@qnx.com