Here's a simple program to reproduce the issue. On my machine,
a difference is output many times every second (apparently,
when the clock is very close to an integer number of seconds).
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
const char fname[] = "timetest.txt";
int main(void)
{
while (1)
{
struct stat st;
FILE *f;
time_t t;
f = fopen(fname, "w");
if (f == NULL)
exit(1);
fclose(f);
t = time(NULL);
if (stat(fname, &st) != 0)
exit(1);
if (t < st.st_mtime)
printf("%ld %ld\n", (long) t, (long) st.st_mtime);
}
}
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)