Bug in TIME function
tlake@twcny.rr.com
tlake@twcny.rr.com
Fri Sep 13 11:37:00 GMT 2019
In Linux it returns a time value and return code of 0:
tom@LinuxPC:~/Downloads$ ./timetest
return value 10452
errno 0
Success
tom@LinuxPC:~/Downloads$ ./timetest
return value 14048
errno 0
Success
-----Original Message-----
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
Sent: Thursday, September 12, 2019 02:45 PM
To: cygwin@cygwin.com
Subject: Re: Bug in TIME function
On 2019-09-12 12:05, tlake@twcny.rr.com wrote:
> The code below returns -1. It shouldn't.
> #include <sys/times.h>
> #include <stdio.h>
> int main(int argc, char *argv[])
> {
> printf("return value %ld\n", (long)times((struct tms*)0));
> return 0;
> }
It should.
The times(3) function requires a pointer to object storage to return the results which are its function.
An invalid pointer to object storage is an error, requiring -1 be returned and errno set.
You should also print errno and strerror(errno).
--
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
More information about the Cygwin
mailing list