Sree I
03/25/2009 8:35 AM
post25159
|
I have written a piece of code to get the kernel boot-time but it returns the error "No such file or directory". Where
does it try to look this up from ? Couldn't find anything in the documentation.
While browsing for this, saw somewhere about a file called /kernel/boottime. My installation doesn't have a /kernel
directory.
thanks
Sree.
#include <sys/time.h>
#include <sys/sysctl.h>
#include <errno.h>
int
main (struct timeval *tv, struct timezone *tz)
{
struct timeval boot = { 0, 0 };
int mib[2] = {CTL_KERN, KERN_BOOTTIME};
size_t size;
size = sizeof (boot);
if (sysctl (mib, 2, &boot, &size, NULL, 0) < 0)
perror ("Boot time : ");
return 0;
}
|
|
|