Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

alarm - schedule alarm signal

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

Optional
#include <signal.h> (End)

unsigned int alarm(unsigned int seconds);

Description

alarm() causes the system to send the calling process a SIGALRM signal after the number
of real-time seconds specified by seconds have elapsed (see also signal.h).

If seconds is 0, a pending alarm request, if any, is cancelled.

Alarm requests are not stacked; only one SIGALRM generation can be scheduled in this
manner; if the SIGALRM signal has not yet been generated, the call will result in
rescheduling the time at which the SIGALRM signal will be generated.

Interactions between alarm() and the functions setitimer(), ualarm() and
usleep() are not defined.

If threads are used, then the function affects the process or a thread in the following
manner:

  • A SIGALRM signal is generated for the process when the specified time limit has expired.

    BS2000

  • If the signal is not caught (see also signal()), the program is terminated with exit(-1). (End)

Return val.

Number of seconds until the generation of a SIGALRM signal 


 if there is a previous alarm request with time remaining on the alarm clock.

0

 if there is no pending alarm request.

alarm() is always successful. 

Notes

fork() clears pending alarms in the child process. A new process image created by one
of the exec functions inherits the time left to an alarm signal in the old process image.

Processor scheduling delays may prevent the process from handling the signal as soon as
it is generated.

BS2000
SIGALRM corresponds to the STXIT event class RTIMER (real-time interval timer). (End) 

See also

exec(), fork(), pause(), sigaction(), signal.h, unistd.h, section “Signals”