]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/sigaction.2
zfs: merge openzfs/zfs@a0b2a93c4
[FreeBSD/FreeBSD.git] / lib / libc / sys / sigaction.2
1 .\" Copyright (c) 1980, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .Dd December 1, 2023
29 .Dt SIGACTION 2
30 .Os
31 .Sh NAME
32 .Nm sigaction
33 .Nd software signal facilities
34 .Sh LIBRARY
35 .Lb libc
36 .Sh SYNOPSIS
37 .In signal.h
38 .Bd -literal
39 struct  sigaction {
40         void    (*sa_handler)(int);
41         void    (*sa_sigaction)(int, siginfo_t *, void *);
42         int     sa_flags;               /* see signal options below */
43         sigset_t sa_mask;               /* signal mask to apply */
44 };
45 .Ed
46 .Pp
47 .Ft int
48 .Fo sigaction
49 .Fa "int sig"
50 .Fa "const struct sigaction * restrict act"
51 .Fa "struct sigaction * restrict oact"
52 .Fc
53 .Sh DESCRIPTION
54 The system defines a set of signals that may be delivered to a process.
55 Signal delivery resembles the occurrence of a hardware interrupt:
56 the signal is normally blocked from further occurrence, the current thread
57 context is saved, and a new one is built.
58 A process may specify a
59 .Em handler
60 to which a signal is delivered, or specify that a signal is to be
61 .Em ignored .
62 A process may also specify that a default action is to be taken
63 by the system when a signal occurs.
64 A signal may also be
65 .Em blocked
66 for a thread,
67 in which case it will not be delivered to that thread until it is
68 .Em unblocked .
69 The action to be taken on delivery is determined at the time
70 of delivery.
71 Normally, signal handlers execute on the current stack
72 of the thread.
73 This may be changed, on a per-handler basis,
74 so that signals are taken on a special
75 .Em "signal stack" .
76 .Pp
77 Signal routines normally execute with the signal that caused their
78 invocation
79 .Em blocked ,
80 but other signals may yet occur.
81 A global
82 .Em "signal mask"
83 defines the set of signals currently blocked from delivery
84 to a thread.
85 The signal mask for a thread is initialized
86 from that of its parent (normally empty).
87 It may be changed with a
88 .Xr sigprocmask 2
89 or
90 .Xr pthread_sigmask 3
91 call, or when a signal is delivered to the thread.
92 .Pp
93 When a signal
94 condition arises for a process or thread, the signal is added to a set of
95 signals pending for the process or thread.
96 Whether the signal is directed at the process in general or at a specific
97 thread depends on how it is generated.
98 For signals directed at a specific thread,
99 if the signal is not currently
100 .Em blocked
101 by the thread then it is delivered to the thread.
102 For signals directed at the process,
103 if the signal is not currently
104 .Em blocked
105 by all threads then it is delivered to one thread that does not have it blocked
106 (the selection of which is unspecified).
107 Signals may be delivered any time a thread enters the operating system
108 (e.g., during a system call, page fault or trap, or clock interrupt).
109 If multiple signals are ready to be delivered at the same time,
110 any signals that could be caused by traps are delivered first.
111 Additional signals may be processed at the same time, with each
112 appearing to interrupt the handlers for the previous signals
113 before their first instructions.
114 The set of pending signals is returned by the
115 .Xr sigpending 2
116 system call.
117 When a caught signal
118 is delivered, the current state of the thread is saved,
119 a new signal mask is calculated (as described below),
120 and the signal handler is invoked.
121 The call to the handler
122 is arranged so that if the signal handling routine returns
123 normally the thread will resume execution in the context
124 from before the signal's delivery.
125 If the thread wishes to resume in a different context, then it
126 must arrange to restore the previous context itself.
127 .Pp
128 When a signal is delivered to a thread a new signal mask is
129 installed for the duration of the process' signal handler
130 (or until a
131 .Xr sigprocmask 2
132 system call is made).
133 This mask is formed by taking the union of the current signal mask set,
134 the signal to be delivered, and
135 the signal mask associated with the handler to be invoked.
136 .Pp
137 The
138 .Fn sigaction
139 system call
140 assigns an action for a signal specified by
141 .Fa sig .
142 If
143 .Fa act
144 is non-NULL, it specifies an action
145 .Dv ( SIG_DFL ,
146 .Dv SIG_IGN ,
147 or a handler routine) and mask to be used when delivering the specified signal.
148 If
149 .Fa oact
150 is non-NULL, the previous handling information for the signal
151 is returned to the user.
152 .Pp
153 The above declaration of
154 .Vt "struct sigaction"
155 is not literal.
156 It is provided only to list the accessible members.
157 See
158 .In sys/signal.h
159 for the actual definition.
160 In particular, the storage occupied by
161 .Va sa_handler
162 and
163 .Va sa_sigaction
164 overlaps, and it is nonsensical for an application to attempt to use both
165 simultaneously.
166 .Pp
167 Once a signal handler is installed, it normally remains installed
168 until another
169 .Fn sigaction
170 system call is made, or an
171 .Xr execve 2
172 is performed.
173 A signal-specific default action may be reset by
174 setting
175 .Va sa_handler
176 to
177 .Dv SIG_DFL .
178 The defaults are process termination, possibly with core dump;
179 no action; stopping the process; or continuing the process.
180 See the signal list below for each signal's default action.
181 If
182 .Va sa_handler
183 is
184 .Dv SIG_DFL ,
185 the default action for the signal is to discard the signal,
186 and if a signal is pending,
187 the pending signal is discarded even if the signal is masked.
188 If
189 .Va sa_handler
190 is set to
191 .Dv SIG_IGN
192 current and pending instances
193 of the signal are ignored and discarded.
194 .Pp
195 Options may be specified by setting
196 .Va sa_flags .
197 The meaning of the various bits is as follows:
198 .Bl -tag -offset indent -width SA_RESETHANDXX
199 .It Dv SA_NOCLDSTOP
200 If this bit is set when installing a catching function
201 for the
202 .Dv SIGCHLD
203 signal,
204 the
205 .Dv SIGCHLD
206 signal will be generated only when a child process exits,
207 not when a child process stops.
208 .It Dv SA_NOCLDWAIT
209 If this bit is set when calling
210 .Fn sigaction
211 for the
212 .Dv SIGCHLD
213 signal, the system will not create zombie processes when children of
214 the calling process exit.
215 If the calling process subsequently issues a
216 .Xr wait 2
217 (or equivalent), it blocks until all of the calling process's child
218 processes terminate, and then returns a value of \-1 with
219 .Va errno
220 set to
221 .Er ECHILD .
222 The same effect of avoiding zombie creation can also be achieved by setting
223 .Va sa_handler
224 for
225 .Dv SIGCHLD
226 to
227 .Dv SIG_IGN .
228 .It Dv SA_ONSTACK
229 If this bit is set, the system will deliver the signal to the process
230 on a
231 .Em "signal stack" ,
232 specified by each thread with
233 .Xr sigaltstack 2 .
234 .It Dv SA_NODEFER
235 If this bit is set, further occurrences of the delivered signal are
236 not masked during the execution of the handler.
237 .It Dv SA_RESETHAND
238 If this bit is set, the handler is reset back to
239 .Dv SIG_DFL
240 at the moment the signal is delivered.
241 .It Dv SA_RESTART
242 See paragraph below.
243 .It Dv SA_SIGINFO
244 If this bit is set, the handler function is assumed to be pointed to by the
245 .Va sa_sigaction
246 member of
247 .Vt "struct sigaction"
248 and should match the prototype shown above or as below in
249 .Sx EXAMPLES .
250 This bit should not be set when assigning
251 .Dv SIG_DFL
252 or
253 .Dv SIG_IGN .
254 .El
255 .Pp
256 If a signal is caught during the system calls listed below,
257 the call may be forced to terminate
258 with the error
259 .Er EINTR ,
260 the call may return with a data transfer shorter than requested,
261 or the call may be restarted.
262 Restart of pending calls is requested
263 by setting the
264 .Dv SA_RESTART
265 bit in
266 .Va sa_flags .
267 The affected system calls include
268 .Xr open 2 ,
269 .Xr read 2 ,
270 .Xr write 2 ,
271 .Xr sendto 2 ,
272 .Xr recvfrom 2 ,
273 .Xr sendmsg 2
274 and
275 .Xr recvmsg 2
276 on a communications channel or a slow device (such as a terminal,
277 but not a regular file)
278 and during a
279 .Xr wait 2
280 or
281 .Xr ioctl 2 .
282 However, calls that have already committed are not restarted,
283 but instead return a partial success (for example, a short read count).
284 .Pp
285 After a
286 .Xr pthread_create 3
287 the signal mask is inherited by the new thread and
288 the set of pending signals and the signal stack for the new thread are empty.
289 .Pp
290 After a
291 .Xr fork 2
292 or
293 .Xr vfork 2
294 all signals, the signal mask, the signal stack,
295 and the restart/interrupt flags are inherited by the child.
296 .Pp
297 The
298 .Xr execve 2
299 system call reinstates the default
300 action for all signals which were caught and
301 resets all signals to be caught on the user stack.
302 Ignored signals remain ignored;
303 the signal mask remains the same;
304 signals that restart pending system calls continue to do so.
305 .Pp
306 The following is a list of all signals
307 with names as in the include file
308 .In signal.h :
309 .Bl -column SIGVTALARMXX "create core imagexxx"
310 .It Sy NAME Ta Sy Default Action Ta Sy Description
311 .It Dv SIGHUP Ta terminate process Ta terminal line hangup
312 .It Dv SIGINT Ta terminate process Ta interrupt program
313 .It Dv SIGQUIT Ta create core image Ta quit program
314 .It Dv SIGILL Ta create core image Ta illegal instruction
315 .It Dv SIGTRAP Ta create core image Ta trace trap
316 .It Dv SIGABRT Ta create core image Ta Xr abort 3 call (formerly Dv SIGIOT )
317 .It Dv SIGEMT Ta create core image Ta emulate instruction executed
318 .It Dv SIGFPE Ta create core image Ta floating-point exception
319 .It Dv SIGKILL Ta terminate process Ta kill program
320 .It Dv SIGBUS Ta create core image Ta bus error
321 .It Dv SIGSEGV Ta create core image Ta segmentation violation
322 .It Dv SIGSYS Ta create core image Ta non-existent system call invoked
323 .It Dv SIGPIPE Ta terminate process Ta write on a pipe with no reader
324 .It Dv SIGALRM Ta terminate process Ta real-time timer expired
325 .It Dv SIGTERM Ta terminate process Ta software termination signal
326 .It Dv SIGURG Ta discard signal Ta urgent condition present on socket
327 .It Dv SIGSTOP Ta stop process Ta stop (cannot be caught or ignored)
328 .It Dv SIGTSTP Ta stop process Ta stop signal generated from keyboard
329 .It Dv SIGCONT Ta discard signal Ta continue after stop
330 .It Dv SIGCHLD Ta discard signal Ta child status has changed
331 .It Dv SIGTTIN Ta stop process Ta background read attempted from control terminal
332 .It Dv SIGTTOU Ta stop process Ta background write attempted to control terminal
333 .It Dv SIGIO Ta discard signal Ta I/O is possible on a descriptor (see Xr fcntl 2 )
334 .It Dv SIGXCPU Ta terminate process Ta cpu time limit exceeded (see Xr setrlimit 2 )
335 .It Dv SIGXFSZ Ta terminate process Ta file size limit exceeded (see Xr setrlimit 2 )
336 .It Dv SIGVTALRM Ta terminate process Ta virtual time alarm (see Xr setitimer 2 )
337 .It Dv SIGPROF Ta terminate process Ta profiling timer alarm (see Xr setitimer 2 )
338 .It Dv SIGWINCH Ta discard signal Ta window size change
339 .It Dv SIGINFO Ta discard signal Ta status request from keyboard
340 .It Dv SIGUSR1 Ta terminate process Ta user defined signal 1
341 .It Dv SIGUSR2 Ta terminate process Ta user defined signal 2
342 .El
343 .Sh NOTE
344 The
345 .Va sa_mask
346 field specified in
347 .Fa act
348 is not allowed to block
349 .Dv SIGKILL
350 or
351 .Dv SIGSTOP .
352 Any attempt to do so will be silently ignored.
353 .Pp
354 The following functions are either reentrant or not interruptible
355 by signals and are async-signal safe.
356 Therefore applications may
357 invoke them, without restriction, from signal-catching functions
358 or from a child process after calling
359 .Xr fork 2
360 in a multi-threaded process:
361 .Pp
362 Base Interfaces:
363 .Pp
364 .Fn _Exit ,
365 .Fn _exit ,
366 .Fn accept ,
367 .Fn access ,
368 .Fn alarm ,
369 .Fn bind ,
370 .Fn cfgetispeed ,
371 .Fn cfgetospeed ,
372 .Fn cfsetispeed ,
373 .Fn cfsetospeed ,
374 .Fn chdir ,
375 .Fn chmod ,
376 .Fn chown ,
377 .Fn close ,
378 .Fn connect ,
379 .Fn creat ,
380 .Fn dup ,
381 .Fn dup2 ,
382 .Fn execl ,
383 .Fn execle ,
384 .Fn execv ,
385 .Fn execve ,
386 .Fn faccessat ,
387 .Fn fchdir ,
388 .Fn fchmod ,
389 .Fn fchmodat ,
390 .Fn fchown ,
391 .Fn fchownat ,
392 .Fn fcntl ,
393 .Fn _Fork ,
394 .Fn fstat ,
395 .Fn fstatat ,
396 .Fn fsync ,
397 .Fn ftruncate ,
398 .Fn getegid ,
399 .Fn geteuid ,
400 .Fn getgid ,
401 .Fn getgroups ,
402 .Fn getpeername ,
403 .Fn getpgrp ,
404 .Fn getpid ,
405 .Fn getppid ,
406 .Fn getsockname ,
407 .Fn getsockopt ,
408 .Fn getuid ,
409 .Fn kill ,
410 .Fn link ,
411 .Fn linkat ,
412 .Fn listen ,
413 .Fn lseek ,
414 .Fn lstat ,
415 .Fn mkdir ,
416 .Fn mkdirat ,
417 .Fn mkfifo ,
418 .Fn mkfifoat ,
419 .Fn mknod ,
420 .Fn mknodat ,
421 .Fn open ,
422 .Fn openat ,
423 .Fn pause ,
424 .Fn pipe ,
425 .Fn poll ,
426 .Fn pselect ,
427 .Fn pthread_sigmask ,
428 .Fn raise ,
429 .Fn read ,
430 .Fn readlink ,
431 .Fn readlinkat ,
432 .Fn recv ,
433 .Fn recvfrom ,
434 .Fn recvmsg ,
435 .Fn rename ,
436 .Fn renameat ,
437 .Fn rmdir ,
438 .Fn select ,
439 .Fn send ,
440 .Fn sendmsg ,
441 .Fn sendto ,
442 .Fn setgid ,
443 .Fn setpgid ,
444 .Fn setsid ,
445 .Fn setsockopt ,
446 .Fn setuid ,
447 .Fn shutdown ,
448 .Fn sigaction ,
449 .Fn sigaddset ,
450 .Fn sigdelset ,
451 .Fn sigemptyset ,
452 .Fn sigfillset ,
453 .Fn sigismember ,
454 .Fn signal ,
455 .Fn sigpending ,
456 .Fn sigprocmask ,
457 .Fn sigsuspend ,
458 .Fn sleep ,
459 .Fn sockatmark ,
460 .Fn socket ,
461 .Fn socketpair ,
462 .Fn stat ,
463 .Fn symlink ,
464 .Fn symlinkat ,
465 .Fn tcdrain ,
466 .Fn tcflow ,
467 .Fn tcflush ,
468 .Fn tcgetattr ,
469 .Fn tcgetpgrp ,
470 .Fn tcsendbreak ,
471 .Fn tcsetattr ,
472 .Fn tcsetpgrp ,
473 .Fn time ,
474 .Fn times ,
475 .Fn umask ,
476 .Fn uname ,
477 .Fn unlink ,
478 .Fn unlinkat ,
479 .Fn utime ,
480 .Fn wait ,
481 .Fn waitpid ,
482 .Fn write .
483 .Pp
484 X/Open Systems Interfaces:
485 .Pp
486 .Fn sigpause ,
487 .Fn sigset ,
488 .Fn utimes .
489 .Pp
490 Realtime Interfaces:
491 .Pp
492 .Fn aio_error ,
493 .Fn clock_gettime ,
494 .Fn timer_getoverrun ,
495 .Fn aio_return ,
496 .Fn fdatasync ,
497 .Fn sigqueue ,
498 .Fn timer_gettime ,
499 .Fn aio_suspend ,
500 .Fn sem_post ,
501 .Fn timer_settime .
502 .Pp
503 Base Interfaces not specified as async-signal safe by
504 .Tn POSIX :
505 .Pp
506 .Fn fpathconf ,
507 .Fn pathconf ,
508 .Fn sysconf .
509 .Pp
510 Base Interfaces not specified as async-signal safe by
511 .Tn POSIX ,
512 but planned to be:
513 .Pp
514 .Fn ffs ,
515 .Fn htonl ,
516 .Fn htons ,
517 .Fn memccpy ,
518 .Fn memchr ,
519 .Fn memcmp ,
520 .Fn memcpy ,
521 .Fn memmove ,
522 .Fn memset ,
523 .Fn ntohl ,
524 .Fn ntohs ,
525 .Fn stpcpy ,
526 .Fn stpncpy ,
527 .Fn strcat ,
528 .Fn strchr ,
529 .Fn strcmp ,
530 .Fn strcpy ,
531 .Fn strcspn ,
532 .Fn strlen ,
533 .Fn strncat ,
534 .Fn strncmp ,
535 .Fn strncpy ,
536 .Fn strnlen ,
537 .Fn strpbrk ,
538 .Fn strrchr ,
539 .Fn strspn ,
540 .Fn strstr ,
541 .Fn strtok_r ,
542 .Fn wcpcpy ,
543 .Fn wcpncpy ,
544 .Fn wcscat ,
545 .Fn wcschr ,
546 .Fn wcscmp ,
547 .Fn wcscpy ,
548 .Fn wcscspn ,
549 .Fn wcslen ,
550 .Fn wcsncat ,
551 .Fn wcsncmp ,
552 .Fn wcsncpy ,
553 .Fn wcsnlen ,
554 .Fn wcspbrk ,
555 .Fn wcsrchr ,
556 .Fn wcsspn ,
557 .Fn wcsstr ,
558 .Fn wcstok ,
559 .Fn wmemchr ,
560 .Fn wmemcmp ,
561 .Fn wmemcpy ,
562 .Fn wmemmove ,
563 .Fn wmemset .
564 .Pp
565 Extension Interfaces:
566 .Pp
567 .Fn accept4 ,
568 .Fn bindat ,
569 .Fn close_range ,
570 .Fn closefrom ,
571 .Fn connectat ,
572 .Fn eaccess ,
573 .Fn ffsl ,
574 .Fn ffsll ,
575 .Fn flock ,
576 .Fn fls ,
577 .Fn flsl ,
578 .Fn flsll ,
579 .Fn futimesat ,
580 .Fn pipe2 ,
581 .Fn strlcat .
582 .Fn strlcpy ,
583 .Fn strsep .
584 .Pp
585 In addition, reading or writing
586 .Va errno
587 is async-signal safe.
588 .Pp
589 All functions not in the above lists are considered to be unsafe
590 with respect to signals.
591 That is to say, the behaviour of such
592 functions is undefined when they are called from a signal handler
593 that interrupted an unsafe function.
594 In general though, signal handlers should do little more than set a
595 flag; most other actions are not safe.
596 .Pp
597 Also, it is good practice to make a copy of the global variable
598 .Va errno
599 and restore it before returning from the signal handler.
600 This protects against the side effect of
601 .Va errno
602 being set by functions called from inside the signal handler.
603 .Sh RETURN VALUES
604 .Rv -std sigaction
605 .Sh EXAMPLES
606 There are three possible prototypes the handler may match:
607 .Bl -tag -offset indent -width short
608 .It Tn ANSI C :
609 .Ft void
610 .Fn handler int ;
611 .It Traditional BSD style:
612 .Ft void
613 .Fn handler int "int code" "struct sigcontext *scp" ;
614 .It Tn POSIX Dv SA_SIGINFO :
615 .Ft void
616 .Fn handler int "siginfo_t *info" "ucontext_t *uap" ;
617 .El
618 .Pp
619 The handler function should match the
620 .Dv SA_SIGINFO
621 prototype if the
622 .Dv SA_SIGINFO
623 bit is set in
624 .Va sa_flags .
625 It then should be pointed to by the
626 .Va sa_sigaction
627 member of
628 .Vt "struct sigaction" .
629 Note that you should not assign
630 .Dv SIG_DFL
631 or
632 .Dv SIG_IGN
633 this way.
634 .Pp
635 If the
636 .Dv SA_SIGINFO
637 flag is not set, the handler function should match
638 either the
639 .Tn ANSI C
640 or traditional
641 .Bx
642 prototype and be pointed to by
643 the
644 .Va sa_handler
645 member of
646 .Vt "struct sigaction" .
647 In practice,
648 .Fx
649 always sends the three arguments of the latter and since the
650 .Tn ANSI C
651 prototype is a subset, both will work.
652 The
653 .Va sa_handler
654 member declaration in
655 .Fx
656 include files is that of
657 .Tn ANSI C
658 (as required by
659 .Tn POSIX ) ,
660 so a function pointer of a
661 .Bx Ns -style
662 function needs to be casted to
663 compile without warning.
664 The traditional
665 .Bx
666 style is not portable and since its capabilities
667 are a full subset of a
668 .Dv SA_SIGINFO
669 handler,
670 its use is deprecated.
671 .Pp
672 The
673 .Fa sig
674 argument is the signal number, one of the
675 .Dv SIG...
676 values from
677 .In signal.h .
678 .Pp
679 The
680 .Fa code
681 argument of the
682 .Bx Ns -style
683 handler and the
684 .Va si_code
685 member of the
686 .Fa info
687 argument to a
688 .Dv SA_SIGINFO
689 handler contain a numeric code explaining the
690 cause of the signal, usually one of the
691 .Dv SI_...
692 values from
693 .In sys/signal.h
694 or codes specific to a signal, i.e., one of the
695 .Dv FPE_...
696 values for
697 .Dv SIGFPE .
698 .Pp
699 The
700 .Fa scp
701 argument to a
702 .Bx Ns -style
703 handler points to an instance of
704 .Vt "struct sigcontext" .
705 .Pp
706 The
707 .Fa uap
708 argument to a
709 .Tn POSIX
710 .Dv SA_SIGINFO
711 handler points to an instance of
712 ucontext_t.
713 .Sh ERRORS
714 The
715 .Fn sigaction
716 system call
717 will fail and no new signal handler will be installed if one
718 of the following occurs:
719 .Bl -tag -width Er
720 .It Bq Er EINVAL
721 The
722 .Fa sig
723 argument
724 is not a valid signal number.
725 .It Bq Er EINVAL
726 An attempt is made to ignore or supply a handler for
727 .Dv SIGKILL
728 or
729 .Dv SIGSTOP .
730 .El
731 .Sh SEE ALSO
732 .Xr kill 1 ,
733 .Xr kill 2 ,
734 .Xr ptrace 2 ,
735 .Xr setitimer 2 ,
736 .Xr setrlimit 2 ,
737 .Xr sigaltstack 2 ,
738 .Xr sigpending 2 ,
739 .Xr sigprocmask 2 ,
740 .Xr sigsuspend 2 ,
741 .Xr wait 2 ,
742 .Xr fpsetmask 3 ,
743 .Xr setjmp 3 ,
744 .Xr siginfo 3 ,
745 .Xr siginterrupt 3 ,
746 .Xr sigsetops 3 ,
747 .Xr ucontext 3 ,
748 .Xr tty 4
749 .Sh STANDARDS
750 The
751 .Fn sigaction
752 system call is expected to conform to
753 .St -p1003.1-90 .
754 The
755 .Dv SA_ONSTACK
756 and
757 .Dv SA_RESTART
758 flags are Berkeley extensions,
759 as are the signals,
760 .Dv SIGTRAP ,
761 .Dv SIGEMT ,
762 .Dv SIGBUS ,
763 .Dv SIGSYS ,
764 .Dv SIGURG ,
765 .Dv SIGIO ,
766 .Dv SIGXCPU ,
767 .Dv SIGXFSZ ,
768 .Dv SIGVTALRM ,
769 .Dv SIGPROF ,
770 .Dv SIGWINCH ,
771 and
772 .Dv SIGINFO .
773 Those signals are available on most
774 .Bx Ns \-derived
775 systems.
776 The
777 .Dv SA_NODEFER
778 and
779 .Dv SA_RESETHAND
780 flags are intended for backwards compatibility with other operating
781 systems.
782 The
783 .Dv SA_NOCLDSTOP ,
784 and
785 .Dv SA_NOCLDWAIT
786 .\" and
787 .\" SA_SIGINFO
788 flags are featuring options commonly found in other operating systems.
789 The flags are approved by
790 .St -susv2 ,
791 along with the option to avoid zombie creation by ignoring
792 .Dv SIGCHLD .