Re: [PATCH] Change attachment stamping to use stat st_mtime by default.

Reed Underwood <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
Would it be preferable to just use gettimeofday (or another function 
that guarantees subsecond precision) and use only the seconds?

On 8/20/26 16:16, Kurt Hackenberg wrote:
> On Thu, Aug 20, 2026 at 10:54 +0800, Kevin J. McCarthy wrote:
>
>> Recent Linux kernels have an issue where time() has a lower
>> granularity than the stat st_mtime of a file.  This can result in
>> time() being earlier than the mtime of a file just modified.
>> See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1144613
>
> Oswald is right that it should work to truncate times to the second 
> for comparison. (I guess time() + 1 is a shortcut to the same 
> outcome.) Might be some trouble to do that portably. There's the 
> standard C library function difftime()...
>
> Seems better to do that than to hit the filesystem through stat().
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.