1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
.\" Copyright (c) 1994 Mike Battersby <mike@starbug.apana.org.au>
.\" based on work by faith@cs.unc.edu
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified, aeb, 960424, 960621
.\" Modified Mon Jun 10 21:00:42 1996 by Martin Schulze <joey@linux.de>
.\" Modified Wed Aug 27 21:09:52 1997 by Nicols Lichtmaier <nick@debian.org>
.\"
.\" FIXME - error conditions need to be documented
.TH SIGNAL 2 "21 July 1996" "Linux 2.0" "Linux Programmer's Manual"
.SH NAME
signal \- ANSI C signal handling
.SH SYNOPSIS
.B #include <signal.h>
.sp 2
.B typedef void (*sighandler_t)(int);
.sp 2
.BI "sighandler_t signal(int " signum ", sighandler_t " action );
.SH DESCRIPTION
The
.B signal
system call installs a new signal handler for the signal with number
.I signum.
The signal handler is set to
.I handler
which may be a user specified function, or one of the following:
.RS
.TP
.B SIG_IGN
Ignore the signal.
.TP
.B SIG_DFL
Reset the signal to its default behavior.
.RE
.PP
The integer argument that is handed over to the signal handler routine is the
signal number. This makes it possible to use one signal handler for several
signals.
Signal handlers are called whenever the process receives
the corresponding signal. The default signal handler behaviour varies
among the different signals, these behaviours are documented in
.BR signal (7).
.SH "RETURN VALUE"
.B signal
returns the previous value of the signal handler, or
.B SIG_ERR
on error.
.SH NOTES
Signal handlers cannot be set for
.B SIGKILL
or
.BR SIGSTOP .
.PP
Since libc6,
.B signal
uses BSD semantics and the default behaviour is not reset when the
signal is raised. You may use
.B sysv_signal
to get SysV semantics.
.PP
Both
.BR signal " and " sysv_signal
are library routines built on top of
.BR sigaction (2).
.PP
According to POSIX, the behaviour of a process is undefined after it
ignores a
.BR SIGFPE ", " SIGILL ", or " SIGSEGV
signal that was not generated
by the
.BR kill (2)
or the
.BR raise (2)
functions.
Integer division by zero has undefined result.
On some architectures it will generate a
.B SIGFPE
signal (dividing the most negative integer by \-1 may also generate \fBSIGFPE\fP).
Ignoring this signal might lead to an endless loop.
.PP
According to POSIX (B.3.3.1.3) you must not set the action for \fBSIGCHLD\fP
to \fBSIG_IGN\fP. Here the BSD and SYSV behaviours differ, causing BSD software
that sets the action for \fBSIGCHLD\fP to \fBSIG_IGN\fP to fail on Linux.
.PP
The use of the
.B sighandler_t
is a GNU extension, and the type is only present when
.B _GNU_SOURCE
is defined.
.SH "CONFORMING TO"
ANSI C
.SH "SEE ALSO"
.BR kill (1),
.BR kill (2),
.BR killpg (2),
.BR pause (2),
.BR raise (3),
.BR sigaction (2),
.BR signal (7),
.BR sigsetops (3),
.BR sigvec (2),
.BR alarm (2)
|