Subject: Re: alarm(4G)?
To: None <current-users@netbsd.org>
From: Geoff Wing <mason@primenet.com.au>
List: current-users
Date: 01/07/1999 07:25:36
Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de> typed:
:According to the manpage, alarm(3) has an unsigned int as argument, but
:the same manpages states that the maximim number of seconds allowed is
:2147483647 which sounds like a signed int. Why?
Why alarm(unsigned int) or why the limit < max unsigned int?
1) Are we presuming a size of int? Is that safe to do? OK, looking
through our current limits, yes.
2) Looking up the Single Unix Spec. v2 on OpenGroup's server and HP/UX,
Digital, and Solaris pages:
unsigned int alarm(unsigned int)
is specified by XPG4/SU[DS]2 - and implementations tend to use
int setitimer(int, const struct itimerval *, struct itimerval *)
SUD2 says: We use:
struct itimerval { | struct itimerval {
struct timeval it_interval; | struct timeval it_interval;
struct timeval it_value; | struct timeval it_value;
} | }
struct timeval { | struct timeval {
time_t tv_sec; | long tv_sec;
suseconds_t tv_usec; | long tv_usec;
} | }
Our longs are at least 32 bits and signed so 2^31-1 is a reasonable limit.
And you're a sicko if you want to set an alarm more than 68 years ahead.
3) Note: they also say:
"The alarm() function always succeeds; no return value is reserved
to indicate an error." (errno is set upon error on Digital)
We have ((unsigned int) -1) as an error.
4) Another interesting thing: <sys/syslimits.h>
#define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */
#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */
^^
yeah?
Regards,
--
Geoff Wing <gcw@pobox.com> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/