stat() whacks st_atime

Jason Tishler
Thu Jul 26 07:40:00 GMT 2001

I'm trying to track down why st_atime gets "whacked" when calling
stat().  By "whacked," I mean set to the current time (or thereabouts).

The attached program, stest.c, demonstrates the problem.  If one calls
it repeatedly, then the specified file's st_atime keeps changing.

I've tracked down the problem to the following (in

    fhandler_base::close (void)
      int res = -1;

      syscall_printf ("handle %p", get_handle());
[1]   if (CloseHandle (get_handle()))
[2]     res = 0;

The st_atime is actually not affected directly by stat() and if stest is
stopped at [1] above, then the file's st_atime value is still unchanged
(as verified by a Win32 program).  If gdb continues to [2], then the
file's st_atime has been changed.

Unfortunately, I cannot figure out what is affecting the change.  Is
there a Cygwin background thread that wakes up when the handle is
closed and somehow affects the file's st_atime?  Or, can CloseHandle()
itself somehow be the culprit.  I'm really perplexed.

Does anyone understand what is going on?

BTW, this issue prevents mutt from detecting new mail in mbox folders.
I was able to temporarily workaround this issue by reconfiguring with


Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email:
Hazlet, NJ 07730 USA                 WWW:

More information about the Cygwin-developers mailing list