This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in TIME function


On 2019-09-13 16:14, Kaz Kylheku wrote:
> On 2019-09-13 12:11, Wayne Davison wrote:
>> On Fri, Sep 13, 2019 at 4:27 AM wrote:
>>> In Linux [times()] returns a time value and return code of 0:
>>
>> The Linux man page for times() mentions this special behavior, how it
>> isn't portable, and even advises against using the function:
>>
>> "On Linux, the buf argument can be specified as NULL, with the result
>> that times() just returns a function result. However, POSIX does not
>> specify this behavior, and most other UNIX implementations require a
>> non-NULL value for buf."
> 
> Ah, so it is a documented extension in Linux, after all. In that case,
> Cygwin should support it.
> 
>> One might argue that it would be nice to emulate the Linux behavior,
>> but it's not required by POSIX.
> 
> Cygwin's explicit motto is "Get that Linux feeling --- on Windows";
> and a tiny part of the Linux feeling is that times(NULL) works.

For functions returning data, -1/EFAULT should be considered a feature, except
if you only want some approximation of elapsed wall clock time from an arbitrary
epoch, which may overflow or change any time, and for which there are functions
better suited with differing resolutions.

For me, that return value is about the same as Cygwin uptime and net stats
workstation:

$ uptime
 14:10:56 up 68 days,  1:54,  3 users,  load average: 1.17, 1.12, 1.11
$ net stats workstation
"Workstation Statistics for \\...

Statistics since 2019-07-10 12:18:35
..."

which is a couple of minutes less than:

$ wmic os get LastBootUpTime
LastBootUpTime
20190710121614.432467-360

and the return value from clock_gettime(CLOCK_BOOTTIME,...).

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]