1signal(3C) Standard C Library Functions signal(3C)
2
3
4
6 signal, sigset, sighold, sigrelse, sigignore, sigpause - simplified
7 signal management for application processes
8
10 #include <signal.h>
11
12 void (*signal(int sig, void (*disp)(int)))(int);
13
14
15 void (*sigset(int sig, void (*disp)(int)))(int);
16
17
18 int sighold(int sig);
19
20
21 int sigrelse(int sig);
22
23
24 int sigignore(int sig);
25
26
27 int sigpause(int sig);
28
29
31 These functions provide simplified signal management for application
32 processes. See signal.h(3HEAD) for an explanation of general signal
33 concepts.
34
35
36 The signal() and sigset() functions modify signal dispositions. The sig
37 argument specifies the signal, which may be any signal except SIGKILL
38 and SIGSTOP. The disp argument specifies the signal's disposition,
39 which may be SIG_DFL, SIG_IGN, or the address of a signal handler. If
40 signal() is used, disp is the address of a signal handler, and sig is
41 not SIGILL, SIGTRAP, or SIGPWR, the system first sets the signal's
42 disposition to SIG_DFL before executing the signal handler. If
43 sigset() is used and disp is the address of a signal handler, the sys‐
44 tem adds sig to the calling process's signal mask before executing the
45 signal handler; when the signal handler returns, the system restores
46 the calling process's signal mask to its state prior to the delivery of
47 the signal. In addition, if sigset() is used and disp is equal to
48 SIG_HOLD, sig is added to the calling process's signal mask and the
49 signal's disposition remains unchanged.
50
51
52 The sighold() function adds sig to the calling process's signal mask.
53
54
55 The sigrelse() function removes sig from the calling process's signal
56 mask.
57
58
59 The sigignore() function sets the disposition of sig to SIG_IGN.
60
61
62 The sigpause() function removes sig from the calling process's signal
63 mask and suspends the calling process until a signal is received.
64
66 Upon successful completion, signal() returns the signal's previous dis‐
67 position. Otherwise, it returns SIG_ERR and sets errno to indicate the
68 error.
69
70
71 Upon successful completion, sigset() returns SIG_HOLD if the signal had
72 been blocked or the signal's previous disposition if it had not been
73 blocked. Otherwise, it returns SIG_ERR and sets errno to indicate the
74 error.
75
76
77 Upon successful completion, sighold(), sigrelse(), sigignore(), and
78 sigpause(), return 0. Otherwise, they return −1 and set errno to
79 indicate the error.
80
82 These functions fail if:
83
84 EINTR A signal was caught during the execution sigpause().
85
86
87 EINVAL The value of the sig argument is not a valid signal or is
88 equal to SIGKILL or SIGSTOP.
89
90
92 The sighold() function used in conjunction with sigrelse() or sig‐
93 pause() may be used to establish critical regions of code that require
94 the delivery of a signal to be temporarily deferred.
95
96
97 If signal() or sigset() is used to set SIGCHLD's disposition to a sig‐
98 nal handler, SIGCHLD will not be sent when the calling process's chil‐
99 dren are stopped or continued.
100
101
102 If any of the above functions are used to set SIGCHLD's disposition to
103 SIG_IGN, the calling process's child processes will not create zombie
104 processes when they terminate (see exit(2)). If the calling process
105 subsequently waits for its children, it blocks until all of its chil‐
106 dren terminate; it then returns −1 with errno set to ECHILD (see
107 wait(3C) and waitid(2)).
108
109
110 The system guarantees that if more than one instance of the same signal
111 is generated to a process, at least one signal will be received. It
112 does not guarantee the reception of every generated signal.
113
115 See attributes(5) for descriptions of the following attributes:
116
117
118
119
120 ┌─────────────────────────────┬─────────────────────────────┐
121 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
122 ├─────────────────────────────┼─────────────────────────────┤
123 │Interface Stability │Standard │
124 ├─────────────────────────────┼─────────────────────────────┤
125 │MT-Level │MT-Safe │
126 └─────────────────────────────┴─────────────────────────────┘
127
129 exit(2), kill(2), pause(2), sigaction(2), sigsend(2), waitid(2), sig‐
130 nal.h(3HEAD), wait(3C), attributes(5), standards(5)
131
132
133
134SunOS 5.11 6 Sep 2007 signal(3C)