1alarm(2) System Calls alarm(2)
2
3
4
6 alarm - schedule an alarm signal
7
9 #include <unistd.h>
10
11 unsigned int alarm(unsigned int seconds);
12
13
15 The alarm() function causes the system to generate a SIGALRM signal for
16 the process after the number of real-time seconds specified by seconds
17 have elapsed (see signal.h(3HEAD)). Processor scheduling delays may
18 prevent the process from handling the signal as soon as it is gener‐
19 ated.
20
21
22 If seconds is 0, a pending alarm request, if any, is cancelled. If sec‐
23 onds is greater than LONG_MAX/hz, seconds is rounded down to
24 LONG_MAX/hz. The value of hz is normally 100.
25
26
27 Alarm requests are not stacked; only one SIGALRM generation can be
28 scheduled in this manner; if the SIGALRM signal has not yet been gener‐
29 ated, the call will result in rescheduling the time at which the
30 SIGALRM signal will be generated.
31
32
33 The fork(2) function clears pending alarms in the child process. A new
34 process image created by one of the exec(2) functions inherits the time
35 left to an alarm signal in the old process's image.
36
38 If there is a previous alarm request with time remaining, alarm()
39 returns a non-zero value that is the number of seconds until the
40 previous request would have generated a SIGALRM signal. Otherwise,
41 alarm() returns 0.
42
44 The alarm() function is always successful; no return value is reserved
45 to indicate an error.
46
48 See attributes(5) for descriptions of the following attributes:
49
50
51
52
53 ┌─────────────────────────────┬─────────────────────────────┐
54 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
55 ├─────────────────────────────┼─────────────────────────────┤
56 │Interface Stability │Standard │
57 ├─────────────────────────────┼─────────────────────────────┤
58 │MT-Level │Async-Signal-Safe │
59 └─────────────────────────────┴─────────────────────────────┘
60
62 exec(2), fork(2), signal.h(3HEAD), attributes(5), standards(5)
63
64
65
66SunOS 5.11 6 Jun 2007 alarm(2)