1sigvec(3UCB)       SunOS/BSD Compatibility Library Functions      sigvec(3UCB)
2
3
4

NAME

6       sigvec - software signal facilities
7

SYNOPSIS

9       /usr/ucb/cc [ flag ... ] file...
10       #include <signal.h>
11
12       int sigvec(sig, nvec, ovec)
13       int sig;
14       struct sigvec *nvec, *ovec;
15
16

DESCRIPTION

18       The system defines a set of signals that may be delivered to a process.
19       Signal delivery resembles the occurrence of a hardware  interrupt:  the
20       signal  is blocked from further occurrence, the current process context
21       is saved, and a new one is built.  A process may specify a  handler  to
22       which  a signal is delivered, or specify that a signal is to be blocked
23       or ignored. A process may also specify that a default action is  to  be
24       taken  by  the  system  when a signal occurs. Normally, signal handlers
25       execute on the current stack of the process.  This may be changed, on a
26       per-handler basis, so that signals are taken on a special signal stack.
27
28
29       All  signals  have  the same priority. Signal routines execute with the
30       signal that caused their invocation to be blocked,  but  other  signals
31       may  yet  occur.  A  global signal mask defines the set of signals cur‐
32       rently blocked from delivery to a  process.   The  signal  mask  for  a
33       process is initialized from that of its parent (normally 0).  It may be
34       changed with a sigblock() or sigsetmask() call, or  when  a  signal  is
35       delivered to the process.
36
37
38       A  process may also specify a set of flags for a signal that affect the
39       delivery of that signal.
40
41
42       When a signal condition arises for a process, the signal is added to  a
43       set of signals pending for the process.  If the signal is not currently
44       blocked by the process then it is delivered to  the  process.   When  a
45       signal  is  delivered, the current state of the process is saved, a new
46       signal mask is calculated (as described below), and the signal  handler
47       is  invoked.  The call to the handler is arranged so that if the signal
48       handling routine returns normally the process will resume execution  in
49       the  context  from before the signal's delivery.  If the process wishes
50       to resume in a different context, then it must arrange to  restore  the
51       previous context itself.
52
53
54       When  a signal is delivered to a process a new signal mask is installed
55       for the duration of the process' signal handler (or until a  sigblock()
56       or  sigsetmask() call is made).  This mask is formed by taking the cur‐
57       rent signal mask, adding the signal to be delivered, and ORing  in  the
58       signal mask associated with the handler to be invoked.
59
60
61       The  action  to be taken when the signal is delivered is specified by a
62       sigvec() structure, which includes the following members:
63
64         void      (*sv_handler)();        /* signal handler */
65         int       sv_mask;        /* signal mask to apply */
66         int       sv_flags;       /* see signal options */
67         #define   SV_ONSTACK      /* take signal on signal stack */
68         #define   SV_INTERRUPT    /* do not restart system on signal
69                                      return */
70         #define   SV_RESETHAND    /* reset handler to SIG_DFL when
71                                      signal taken*/
72
73
74
75       If the SV_ONSTACK bit is set in the flags for that signal,  the  system
76       will  deliver  the  signal to the process on the signal stack specified
77       with sigstack(3UCB) rather than delivering the signal  on  the  current
78       stack.
79
80
81       If  nvec  is not a NULL pointer, sigvec() assigns the handler specified
82       by sv_handler(), the mask specified by sv_mask(), and the flags  speci‐
83       fied by sv_flags() to the specified signal.  If nvec is a NULL pointer,
84       sigvec() does not change the handler, mask, or flags for the  specified
85       signal.
86
87
88       The mask specified in nvec is not allowed to block SIGKILL, SIGSTOP, or
89       SIGCONT. The system enforces this restriction silently.
90
91
92       If ovec is not a NULL pointer, the handler, mask, and flags  in  effect
93       for the signal before the call to sigvec() are returned to the user.  A
94       call to sigvec() with nvec a NULL pointer and ovec not a  NULL  pointer
95       can  be  used to determine the handling information currently in effect
96       for a signal without changing that information.
97
98
99       The following is a list of all signals with names  as  in  the  include
100       file <signal.h>:
101
102       SIGHUP       hangup
103
104
105       SIGINT       interrupt
106
107
108       SIGQUIT*     quit
109
110
111       SIGILL*      illegal instruction
112
113
114       SIGTRAP*     trace trap
115
116
117       SIGABRT*     abort (generated by abort(3C) routine)
118
119
120       SIGEMT*      emulator trap
121
122
123       SIGFPE*      arithmetic exception
124
125
126       SIGKILL      kill (cannot be caught, blocked, or ignored)
127
128
129       SIGBUS*      bus error
130
131
132       SIGSEGV*     segmentation violation
133
134
135       SIGSYS*      bad argument to function
136
137
138       SIGPIPE      write on a pipe or other socket with no one to read it
139
140
141       SIGALRM      alarm clock
142
143
144       SIGTERM      software termination signal
145
146
147       SIGURG*      urgent condition present on socket
148
149
150       SIGSTOP**    stop (cannot be caught, blocked, or ignored)
151
152
153       SIGTSTP**    stop signal generated from keyboard
154
155
156       SIGCONT*     continue after stop (cannot be blocked)
157
158
159       SIGCHLD*     child status has changed
160
161
162       SIGTTIN**    background read attempted from control terminal
163
164
165       SIGTTOU**    background write attempted to control terminal
166
167
168       SIGIO*       I/O is possible on a descriptor (see fcntl(2))
169
170
171       SIGXCPU      cpu time limit exceeded (see getrlimit(2))
172
173
174       SIGXFSZ      file size limit exceeded (see getrlimit(2))
175
176
177       SIGVTALRM    virtual time alarm; see setitimer() on getitimer(2)
178
179
180       SIGPROF      profiling timer alarm; see setitimer() on getitimer(2)
181
182
183       SIGWINCH*    window changed (see termio(7I))
184
185
186       SIGLOST      resource lost (see lockd(1M))
187
188
189       SIGUSR1      user-defined signal 1
190
191
192       SIGUSR2      user-defined signal 2
193
194
195
196       The  starred signals in the list above cause a core image if not caught
197       or ignored.
198
199
200       Once a signal handler is installed, it remains installed until  another
201       sigvec()  call  is  made,  or  an  execve(2)  is  performed, unless the
202       SV_RESETHAND bit is set in the flags for that signal.   In  that  case,
203       the  value  of the handler for the caught signal will be set to SIG_DFL
204       before entering the signal-catching function, unless the signal is SIG‐
205       ILL,  SIGPWR,  or  SIGTRAP.  Also, if this bit is set, the bit for that
206       signal in the signal mask will not be set; unless the signal mask asso‐
207       ciated with that signal blocks that signal, further occurrences of that
208       signal will not be blocked. The SV_RESETHAND flag is not  available  in
209       4.2BSD,  hence  it  should  not  be  used  if backward compatibility is
210       needed.
211
212
213       The default action for a signal may be reinstated by setting  the  sig‐
214       nal's  handler  to SIG_DFL; this default is termination except for sig‐
215       nals marked with * or **.  Signals marked with * are discarded  if  the
216       action is SIG_DFL; signals marked with ** cause the process to stop. If
217       the process is terminated, a "core image" will be made in  the  current
218       working  directory  of  the  receiving process if the signal is one for
219       which an asterisk appears in the above list (see core(4)).
220
221
222       If the handler for that signal is SIG_IGN, the signal  is  subsequently
223       ignored, and pending instances of the signal are discarded.
224
225
226       If  a  caught  signal occurs during certain functions, the call is nor‐
227       mally restarted. The call can be forced to terminate  prematurely  with
228       an  EINTR error return by setting the SV_INTERRUPT bit in the flags for
229       that signal. The SV_INTERRUPT flag is not available in 4.2BSD, hence it
230       should  not  be  used if backward compatibility is needed. The affected
231       functions are read(2) or write(2) on a slow device (such as a  terminal
232       or pipe or other socket, but not a file) and during a wait(3C).
233
234
235       After  a fork(2) or vfork(2) the child inherits all signals, the signal
236       mask, the signal stack, and the restart/interrupt and reset-signal-han‐
237       dler flags.
238
239
240       The  execve(2)  call  resets  all  caught signals to default action and
241       resets all signals to be caught on  the  user  stack.  Ignored  signals
242       remain  ignored;  the signal mask remains the same; signals that inter‐
243       rupt functions continue to do so.
244
245
246       The accuracy  of  addr  is  machine  dependent.  For  example,  certain
247       machines  may supply an address that is on the same page as the address
248       that caused the fault. If an appropriate addr  cannot  be  computed  it
249       will be set to SIG_NOADDR.
250

RETURN VALUES

252       A  0  value  indicates that the call succeeded. A −1 return value indi‐
253       cates that an error occurred and errno is set to indicate the reason.
254

ERRORS

256       sigvec() will fail and no new signal handler will be installed  if  one
257       of the following occurs:
258
259       EFAULT    Either  nvec or ovec is not a NULL pointer and points to mem‐
260                 ory that is not a valid part of the process address space.
261
262
263       EINVAL    sig is not a valid signal number or is SIGKILL or SIGSTOP.
264
265

SEE ALSO

267       Intro(2),  exec(2),  fcntl(2),  fork(2),  getitimer(2),   getrlimit(2),
268       ioctl(2),  kill(2),  read(2), umask(2), vfork(2), write(2), ptrace(3C),
269       setjmp(3C) sigblock(3UCB),  signal(3C),  signal(3UCB),  sigstack(3UCB),
270       wait(3C), wait(3UCB), core(4), streamio(7I), termio(7I)
271

NOTES

273       Use of these interfaces should be restricted to only applications writ‐
274       ten on BSD platforms.  Use of these interfaces with any of  the  system
275       libraries or in multi-thread applications is unsupported.
276
277
278       SIGPOLL  is  a  synonym  for  SIGIO. A SIGIO will be issued when a file
279       descriptor corresponding  to  a  STREAMS  (see  Intro(2))  file  has  a
280       "selectable"  event  pending.  Unless that descriptor has been put into
281       asynchronous mode (see fcntl(2)), a process  may  specifically  request
282       that  this  signal  be  sent  using  the  I_SETSIG  ioctl(2)  call (see
283       streamio(7I)). Otherwise, the process will never receive SIGPOLLs0.
284
285
286       The handler routine can be declared:
287
288         void handler(int sig, int code, struct sigcontext *scp,
289              char *addr);
290
291
292
293       Here sig is the signal number; code is a parameter of  certain  signals
294       that  provides  additional  detail;  scp is a pointer to the sigcontext
295       structure (defined in signal.h),  used  to  restore  the  context  from
296       before the signal; and addr is additional address information.
297
298
299       The signals SIGKILL, SIGSTOP, and SIGCONT cannot be ignored.
300
301
302
303SunOS 5.11                        30 Oct 2007                     sigvec(3UCB)
Impressum