DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

alarm(S)


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(S)].

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(S), fork(S), pause(S), signal(S)

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(S) system call.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005