Subject: Re: alarm(4G)?
To: None <>
From: Geoff Wing <>
List: current-users
Date: 01/07/1999 07:25:36
Hubert Feyrer <> 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) */

Geoff Wing   <>            Mobile : 0412 162 441
Work URL:   Ego URL: