summaryrefslogtreecommitdiff
path: root/man3p/signal.3p
blob: 05d9f55cfe0543650a87cf0dfb4e1a4f6d0a02d3 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "SIGNAL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" signal 
.SH NAME
signal \- signal management
.SH SYNOPSIS
.LP
\fB#include <signal.h>
.br
.sp
void (*signal(int\fP \fIsig\fP\fB, void (*\fP\fIfunc\fP\fB)(int)))(int);
.br
\fP
.SH DESCRIPTION
.LP
Use
of this function is unspecified in a multi-threaded process. 
.LP
The \fIsignal\fP() function chooses one of three ways in which receipt
of the signal number \fIsig\fP is to be subsequently
handled. If the value of \fIfunc\fP is SIG_DFL, default handling for
that signal shall occur. If the value of \fIfunc\fP is
SIG_IGN, the signal shall be ignored. Otherwise, the application shall
ensure that \fIfunc\fP points to a function to be called
when that signal occurs. An invocation of such a function because
of a signal, or (recursively) of any further functions called by
that invocation (other than functions in the standard library), is
called a "signal handler".
.LP
When a signal occurs, and \fIfunc\fP points to a function, it is implementation-defined
whether the equivalent of a:
.sp
.RS
.nf

\fBsignal(\fP\fIsig\fP\fB, SIG_DFL);
\fP
.fi
.RE
.LP
is executed or the implementation prevents some implementation-defined
set of signals (at least including \fIsig\fP) from
occurring until the current signal handling has completed. (If the
value of \fIsig\fP is SIGILL, the implementation may
alternatively define that no action is taken.) Next the equivalent
of:
.sp
.RS
.nf

\fB(*func)(sig);
\fP
.fi
.RE
.LP
is executed. If and when the function returns, if the value of \fIsig\fP
was SIGFPE, SIGILL, or SIGSEGV or any other
implementation-defined value corresponding to a computational exception,
the behavior is undefined. Otherwise, the program shall
resume execution at the point it was interrupted. If the signal occurs
as the result of calling the \fIabort\fP(), \fIraise\fP(),   \fIkill\fP(),
\fIpthread_kill\fP(), or \fIsigqueue\fP()  function, the
signal handler shall not call the \fIraise\fP() function.
.LP
If the signal occurs other than as the result of calling \fIabort\fP(),
\fIraise\fP(),   \fIkill\fP(), \fIpthread_kill\fP(), or \fIsigqueue\fP(),
\ the behavior is undefined if the signal handler refers to any
object with static storage duration other than by assigning a value
to an object declared as volatile \fBsig_atomic_t\fP, or if
the signal handler calls any function in the standard library other
than one of the functions listed in \fISignal Concepts\fP . Furthermore,
if such a call fails, the value of \fIerrno\fP is
unspecified.
.LP
At program start-up, the equivalent of:
.sp
.RS
.nf

\fBsignal(\fP\fIsig\fP\fB, SIG_IGN);
\fP
.fi
.RE
.LP
is executed for some signals, and the equivalent of:
.sp
.RS
.nf

\fBsignal(\fP\fIsig\fP\fB, SIG_DFL);
\fP
.fi
.RE
.LP
is executed for all other signals   \ (see \fIexec\fP). 
.SH RETURN VALUE
.LP
If the request can be honored, \fIsignal\fP() shall return the value
of \fIfunc\fP for the most recent call to \fIsignal\fP()
for the specified signal \fIsig\fP. Otherwise, SIG_ERR shall be returned
and a positive value shall be stored in \fIerrno\fP.
.SH ERRORS
.LP
The \fIsignal\fP() function shall fail if:
.TP 7
.B EINVAL
The \fIsig\fP argument is not a valid signal number or an attempt
is made to catch a signal that cannot be caught or ignore a
signal that cannot be ignored. 
.sp
.LP
The \fIsignal\fP() function may fail if:
.TP 7
.B EINVAL
An
attempt was made to set the action to SIG_DFL for a signal that cannot
be caught or ignored (or both). 
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
The \fIsigaction\fP() function provides a more comprehensive and reliable
mechanism
for controlling signals; new applications should use \fIsigaction\fP()
rather than
\fIsignal\fP().
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fISignal Concepts\fP , \fIexec\fP() , \fIpause\fP() , \fIsigaction\fP()
, \fIsigsuspend\fP() , \fIwaitid\fP() , the Base Definitions volume
of IEEE\ Std\ 1003.1-2001, \fI<signal.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .