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-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


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