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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       signal - signal management
13

SYNOPSIS

15       #include <signal.h>
16
17       void (*signal(int sig, void (*func)(int)))(int);
18
19

DESCRIPTION

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

RETURN VALUE

78       If the request can be honored, signal() shall return the value of  func
79       for the most recent call to signal() for the specified signal sig. Oth‐
80       erwise, SIG_ERR shall be returned and a positive value shall be  stored
81       in errno.
82

ERRORS

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

EXAMPLES

100       None.
101

APPLICATION USAGE

103       The sigaction() function provides a  more  comprehensive  and  reliable
104       mechanism  for  controlling signals; new applications should use sigac‐
105       tion() rather than signal().
106

RATIONALE

108       None.
109

FUTURE DIRECTIONS

111       None.
112

SEE ALSO

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