alarm(2) alarm(2)
NAME
alarm - set process alarm clock
SYNOPSIS
#include <unistd.h>
unsigned alarm(unsigned sec);
DESCRIPTION
alarm instructs the alarm clock of the process to send the
signal SIGALRM to the process after the number of real time
seconds specified by sec have elapsed [see signal(2)].
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.
A newly created process has no pending alarm; they are not
inherited. Any pending alarm is preserved across calls to any
of the exec family of routines.
Return Values
alarm returns the amount of time previously remaining in the
alarm clock of the calling process.
REFERENCES
exec(2), fork(2), pause(2), signal(2)
NOTICES
Considerations for Threads Programming
In multithreaded applications, the alarm signal is delivered
to only the requesting thread, no other.
A thread cannot respond to a signal until it is scheduled for
execution. For multiplexed threads, there may be a time lag
between delivery of the signal and the time it is scheduled to
run. For improved response, consider using bound threads.
Considerations for Lightweight Processes
Internally, alarms are maintained per LWP. The Threads
Library arranges for the signal to be delivered to the
requesting thread, even if the thread has been picked up by
another LWP between the time of request and the time of
response.
Copyright 1994 Novell, Inc. Page 1
alarm(2) alarm(2)
Only the pending alarm (if any) of the calling LWP is
preserved across the exec(2) system call.
Copyright 1994 Novell, Inc. Page 2