1 .\" Copyright (c) 2000 Andries Brouwer <aeb@cwi.nl>
2 .\" based on work by Rik Faith <faith@cs.unc.edu>
3 .\" and Mike Battersby <mike@starbug.apana.org.au>.
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified 2004-11-19, mtk:
26 .\" added pointer to sigaction.2 for details of ignoring SIGCHLD
28 .TH SIGNAL 2 2000-04-28 "Linux 2.2" "Linux Programmer's Manual"
30 signal \- ANSI C signal handling
32 .B #include <signal.h>
34 .B typedef void (*sighandler_t)(int);
36 .BI "sighandler_t signal(int " signum ", sighandler_t " handler );
40 system call installs a new signal handler for the signal with number
42 The signal handler is set to
44 which may be a user specified function, or either
49 Upon arrival of a signal with number
51 the following happens.
52 If the corresponding handler is set to
54 then the signal is ignored.
55 If the handler is set to
57 then the default action associated with the signal (see
60 Finally, if the handler is set to a function
62 then first either the handler is reset to SIG_DFL
63 or an implementation-dependent blocking of the signal
66 is called with argument
69 Using a signal handler function for a signal
70 is called "catching the signal".
75 cannot be caught or ignored.
79 function returns the previous value of the signal handler, or
85 would reset the handler to SIG_DFL, and System V
86 (and the Linux kernel and libc4,5) does the same.
87 On the other hand, BSD does not reset the handler, but blocks
88 new instances of this signal from occurring during a call of the handler.
89 The glibc2 library follows the BSD behaviour.
91 If one on a libc5 system includes
99 and signal has the BSD semantics. This is not recommended.
101 If one on a glibc2 system defines a feature test
106 function, one obtains classical behaviour. This is not recommended.
108 Trying to change the semantics of this call using
109 defines and includes is not a good idea. It is better to avoid
115 The effects of this call in a multi-threaded process are unspecified.
119 must be very careful, since processing elsewhere was interrupted
120 at some arbitrary point. POSIX has the concept of "safe function".
121 If a signal interrupts an unsafe function, and
123 calls an unsafe function, then the behavior is undefined. Safe
124 functions are listed explicitly in the various standards.
125 The POSIX 1003.1-2003 list is
245 According to POSIX, the behaviour of a process is undefined after it
251 signal that was not generated by the
256 Integer division by zero has undefined result.
257 On some architectures it will generate a
260 (Also dividing the most negative integer by \-1 may generate
262 Ignoring this signal might lead to an endless loop.
266 for details on what happens when
274 Various versions of libc predefine this type; libc4 and libc5 define
298 .BR feature_test_macros (7),