Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > A


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


alarm — set a process's alarm clock


#include <unistd.h>

unsigned int alarm(unsigned int sec);


alarm() instructs the alarm clock of the calling process to send the signal SIGALRM to the calling process after the number of real-time seconds specified by sec have elapsed; see signal(5). Specific implementations might place limitations on the maximum supported alarm time. The constant MAX_ALARM defined in <sys/param.h> specifies the implementation-specific maximum. Whenever sec is greater that this maximum, it is silently rounded down to it. On all implementations, MAX_ALARM is guaranteed to be at least 31 days (in seconds).

Alarm requests are not stacked; successive calls reset the alarm clock of the calling process.

If sec is 0, any previously made alarm request is canceled.

Alarms are not inherited by a child process across a fork(), but are inherited across an exec().

On systems that support the getitimer() and setitimer() system calls, the timer mechanism used by alarm() is the same as that used by ITIMER_REAL. Thus successive calls to alarm(), getitimer(), and setitimer() set and return the state of a single timer. In addition, alarm() sets the timer interval to zero.


alarm() returns the amount of time previously remaining in the alarm clock of the calling process.


In some implementations, error bounds for alarm are -1, +0 seconds (for the posting of the alarm, not the restart of the process). Thus a delay of 1 second can return immediately. The setitimer() routine can be used to create a more precise delay.


alarm(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.