1SIGNAL(P)                  POSIX Programmer's Manual                 SIGNAL(P)
2
3
4

NAME

6       signal - signal management
7

SYNOPSIS

9       #include <signal.h>
10
11       void (*signal(int sig, void (*func)(int)))(int);
12
13

DESCRIPTION

15       Use of this function is unspecified in a multi-threaded process.
16
17       The signal() function chooses one of three ways in which receipt of the
18       signal number sig is to be subsequently handled. If the value  of  func
19       is  SIG_DFL, default handling for that signal shall occur. If the value
20       of func is SIG_IGN, the signal shall be ignored. Otherwise, the  appli‐
21       cation  shall  ensure  that func points to a function to be called when
22       that signal occurs. An invocation of such a function because of a  sig‐
23       nal,  or  (recursively) of any further functions called by that invoca‐
24       tion (other than functions in the standard library), is called a  "sig‐
25       nal handler".
26
27       When  a signal occurs, and func points to a function, it is implementa‐
28       tion-defined whether the equivalent of a:
29
30
31              signal(sig, SIG_DFL);
32
33       is executed or the implementation prevents some  implementation-defined
34       set  of  signals (at least including sig) from occurring until the cur‐
35       rent signal handling has completed. (If the value of sig is SIGILL, the
36       implementation  may alternatively define that no action is taken.) Next
37       the equivalent of:
38
39
40              (*func)(sig);
41
42       is executed. If and when the function returns, if the value of sig  was
43       SIGFPE,  SIGILL,  or  SIGSEGV or any other implementation-defined value
44       corresponding to a computational exception, the behavior is  undefined.
45       Otherwise,  the  program  shall  resume  execution  at the point it was
46       interrupted. If the signal occurs as the result of calling the abort(),
47       raise(),    kill(), pthread_kill(), or sigqueue()  function, the signal
48       handler shall not call the raise() function.
49
50       If the signal occurs other than  as  the  result  of  calling  abort(),
51       raise(),    kill(),  pthread_kill(),  or  sigqueue(),   the behavior is
52       undefined if the signal handler refers to any object with static  stor‐
53       age  duration  other than by assigning a value to an object declared as
54       volatile sig_atomic_t, or if the signal handler calls any  function  in
55       the  standard  library other than one of the functions listed in Signal
56       Concepts . Furthermore, if such a call fails, the  value  of  errno  is
57       unspecified.
58
59       At program start-up, the equivalent of:
60
61
62              signal(sig, SIG_IGN);
63
64       is executed for some signals, and the equivalent of:
65
66
67              signal(sig, SIG_DFL);
68
69       is executed for all other signals    (see exec).
70

RETURN VALUE

72       If  the request can be honored, signal() shall return the value of func
73       for the most recent call to signal() for the specified signal sig. Oth‐
74       erwise,  SIG_ERR shall be returned and a positive value shall be stored
75       in errno.
76

ERRORS

78       The signal() function shall fail if:
79
80       EINVAL The sig argument is not a valid signal number or an  attempt  is
81              made  to catch a signal that cannot be caught or ignore a signal
82              that cannot be ignored.
83
84
85       The signal() function may fail if:
86
87       EINVAL An attempt was made to set the action to SIG_DFL  for  a  signal
88              that cannot be caught or ignored (or both).
89
90
91       The following sections are informative.
92

EXAMPLES

94       None.
95

APPLICATION USAGE

97       The  sigaction()  function  provides  a more comprehensive and reliable
98       mechanism for controlling signals; new applications should  use  sigac‐
99       tion() rather than signal().
100

RATIONALE

102       None.
103

FUTURE DIRECTIONS

105       None.
106

SEE ALSO

108       Signal  Concepts  ,  exec()  ,  pause()  , sigaction() , sigsuspend() ,
109       waitid() , the Base Definitions volume of  IEEE Std 1003.1-2001,  <sig‐
110       nal.h>
111
113       Portions  of  this text are reprinted and reproduced in electronic form
114       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
115       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
116       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
117       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
118       event of any discrepancy between this version and the original IEEE and
119       The  Open Group Standard, the original IEEE and The Open Group Standard
120       is the referee document. The original Standard can be  obtained  online
121       at http://www.opengroup.org/unix/online.html .
122
123
124
125IEEE/The Open Group                  2003                            SIGNAL(P)
Impressum