[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: time returns -1



Dale Scheetz writes:

>Thanks for the pointers James. It was a big help. I probably should
>have thought of errno on my own. The man page on time is very
>cryptic. The only technical information it provides is:
>
>If t is not null, the return value is also stored in the memory
>pointed to by t.

Just before that - on mine - it says:

       time returns the time since 00:00:00 GMT, January 1, 1970,
       measured in seconds.

>What it fails to tell you is, if you pass time a null pointer (t) it
>will return an error instead of the time.

If time() behaves this way then fails to follow the C standard, does
it not?  The following works fine on my home machine (0.93R5,
downloaded several months ago and spiced with occasional upgrades):

    #include <time.h>
    #include <stdio.h>

    main()
    {
	time_t t;

	t = time(NULL);
	printf("%ld\n", (long)t);
	return 0;
    }

If this produces output other than the current time (probably around
810000000) then I believe you've found a bug.

>This routine worked fine in ancient times (Debian R2) the way I
>originaly used it. Some time between R2 and R6 the routine changed
>its response to a null pointer, but the man page was not updated to
>reflect the change in behavior. I hope there aren't too many other
>gopher holes waiting out there to be stepped in.
>
>I have heard that GNU is no longer going to support man pages on
>their products, making all updates to the info pages in stead.

The GNU coding standards make some such remark, I believe, but they do
not apply to Debian.

-- 
Richard Kettlewell richard@uk.geeks.org http://www.elmail.co.uk/staff/richard/


Reply to: