It is currently Fri, 18 Jan 2019 00:30:29 GMT

Author Message
 getutxent and Linux
Hi all,

I noticed that the seconds returned by the getutxent() call are not the
same as what's listed as the btime in /proc/stat on the two Linux
systems I've tested on.  The getutxent call always returns a higher

At home, I thought for sure that it was adding the jiffies from the
khubd process (since it was the only one that had a number of jiffies,
converted to seconds, equal to the difference I was detecting).  At
work, however, that doesn't seem to be the case, as I can't find a
process that has a jiffy count that would account exactly for the
difference (and yes, the CLK_TCK rate is the same on both machines -

I was only able to find one other post that mentions a bug in getutxent
(and getutent) on Linux, but no real details.  Does anyone have any more
details on this?

Thanks in advance.


Daniel Berger

PS -  A short C program provided below for your convenience

 * Get the boot time (btime)
#include <utmpx.h>
#include <time.h>
#include <stdio.h>

#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)

int main()
   struct utmpx *u;
   long seconds;

   while((u = getutxent()))

      if(u->ut_type == BOOT_TIME)
         seconds = u->ut_tv.tv_sec;
         printf("Clock tick: %li\n", CLK_TCK);
         printf("Boot seconds: %li\n",seconds);
   return 0;

My results:
Clock tick: 100
Boot seconds: 1019658207
frank-/home/djberge/Programming/C-1684>cat /proc/stat | grep btime
btime 1019658072

 Mon, 13 Dec 2004 20:47:04 GMT   
 getutxent and Linux


getutxent()? What sort of {*filter*}is this? Have you tried getrusage()?


 Mon, 20 Dec 2004 16:25:52 GMT   
 getutxent and Linux

Am I supposed to be looking at ru_utime?  It returns 0 - so does
ru_stime.  Care to provide  an example of how to get the btime using
getrusage()?  Or would you rather just pop off again?


 Fri, 24 Dec 2004 06:18:09 GMT   
   [ 3 post ] 

Similar Threads

1. getutxent()

2. utmpx & getutxent()

3. getutxent

4. deriving login and logouts from getutxent

5. comp.os.linux, comp.os.linux.misc,, comp.os.linux.networking

6. uninstall REDhat linux uninstall REDhat linux uninstall REDhat linux uninstall REDhat linux uninstall REDhat linux uninstall REDhat linux uninstall REDhat linux

7. alt.linux, alt.os.linux, comp.os.linux.redhat

8. comp.os.linux.hardware, comp.os.linux.redhat, linux.redhat.install

9. Linux and W98SE / Ping Linux from W98SE NOT working but can Ping W98SE from Linux

10. disk-sharing (linux/linux, linux/*BSD) ?

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software