alarm(2)


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.

Only the pending alarm (if any) of the calling LWP is preserved across the exec(2) system call.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004