Strange time() vs. stat() bug

naftoli at aecom.UUCP naftoli at aecom.UUCP
Wed Dec 7 04:28:21 AEST 1983


>> If I write to a tty device and then close it, a stat 10 seconds later
>> usually does not show it to have been modified when I did the write+close,
>> but instead, 5 to 10 seconds later!  If I use stat() instead of time() I
>> get the "right" value (which then remains consistent).  Using sync() will
>> also make the value remain consistent (thus "time()" will be OK in the
>> program below).


I took a look at the code to the stat system call and it seems that the
access, change, and mod times are taken straight off the disk as opposed
to the in core version. This answers why sync() clears up the confusion.

As to possible reasons for this, I don't have a clue.  It seems to me
that this should have been detected earlier since programs like
finger(1) will have the terminal idle times only correct as of the last sync().

By the way, the code I looked at was INteractive's System 3.  Probably
the same in standard System III and others also.

Robert Berlinger
Systems Support
{esquire,philabs,cucard}!aecom!naftoli



More information about the Comp.unix.wizards mailing list