1SIGNAL(3C)                                                          SIGNAL(3C)
2
3
4

NAME

6       signal - simplified software signal facilities
7

SYNOPSIS

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

DESCRIPTION

15       Signal  is  a simplified interface to the more general sigvec(2) facil‐
16       ity.
17
18       A signal is generated by some abnormal event, initiated by a user at  a
19       terminal (quit, interrupt, stop), by a program error (bus error, etc.),
20       by request of another program (kill), or  when  a  process  is  stopped
21       because  it  wishes  to  access its control terminal while in the back‐
22       ground (see tty(4)).  Signals are optionally generated when  a  process
23       resumes  after  being  stopped,  when  the  status  of  child processes
24       changes, or when input is ready at the control terminal.  Most  signals
25       cause  termination of the receiving process if no action is taken; some
26       signals instead cause the process receiving them to be stopped, or  are
27       simply  discarded  if  the process has not requested otherwise.  Except
28       for the SIGKILL and SIGSTOP signals, the  signal  call  allows  signals
29       either  to be ignored or to cause an interrupt to a specified location.
30       The following is a list of all signals with names  as  in  the  include
31       file <signal.h>:
32
33       SIGHUP    1    hangup
34       SIGINT    2    interrupt
35       SIGQUIT   3*   quit
36       SIGILL    4*   illegal instruction
37       SIGTRAP   5*   trace trap
38       SIGIOT    6*   IOT instruction
39       SIGEMT    7*   EMT instruction
40       SIGFPE    8*   floating point exception
41       SIGKILL   9    kill (cannot be caught or ignored)
42       SIGBUS    10*  bus error
43       SIGSEGV   11*  segmentation violation
44       SIGSYS    12*  bad argument to system call
45       SIGPIPE   13   write on a pipe with no one to read it
46       SIGALRM   14   alarm clock
47       SIGTERM   15   software termination signal
48       SIGURG    16@  urgent condition present on socket
49       SIGSTOP   17'|+'stop (cannot be caught or ignored)
50       SIGTSTP   18'|+'stop signal generated from keyboard
51       SIGCONT   19@  continue after stop
52       SIGCHLD   20@  child status has changed
53       SIGTTIN   21'|+'background read attempted from control terminal
54       SIGTTOU   22'|+'background write attempted to control terminal
55       SIGIO     23@  i/o is possible on a descriptor (see fcntl(2))
56       SIGXCPU   24   cpu time limit exceeded (see setrlimit(2))
57       SIGXFSZ   25   file size limit exceeded (see setrlimit(2))
58       SIGVTALRM 26   virtual time alarm (see setitimer(2))
59       SIGPROF   27   profiling timer alarm (see setitimer(2))
60       SIGWINCH  28@  Window size change
61       SIGUSR1   30   User defined signal 1
62       SIGUSR2   31   User defined signal 2
63
64       The  starred signals in the list above cause a core image if not caught
65       or ignored.
66
67       If func is SIG_DFL, the default action for signal  sig  is  reinstated;
68       this  default  is  termination  (with a core image for starred signals)
69       except for signals marked with @ or '|+'.  Signals  marked  with  @  are
70       discarded  if  the action is SIG_DFL; signals marked with '|+' cause the
71       process to stop.  If func is SIG_IGN the signal is subsequently ignored
72       and pending instances of the signal are discarded.  Otherwise, when the
73       signal occurs further  occurrences  of  the  signal  are  automatically
74       blocked and func is called.
75
76       A  return  from  the function unblocks the handled signal and continues
77       the process at the point it was interrupted.   Unlike  previous  signal
78       facilities,  the handler func remains installed after a signal has been
79       delivered.
80
81       If a caught signal occurs during certain system calls, causing the call
82       to terminate prematurely, the call is automatically restarted.  In par‐
83       ticular this can occur during a read or write(2) on a slow device (such
84       as a terminal; but not a file) and during a wait(2).
85
86       The  value of signal is the previous (or initial) value of func for the
87       particular signal.
88
89       After a fork(2) or vfork(2) the child inherits all signals.   Execve(2)
90       resets all caught signals to the default action; ignored signals remain
91       ignored.
92

RETURN VALUE

94       The previous action is returned on a successful call.  Otherwise, -1 is
95       returned and errno is set to indicate the error.
96

ERRORS

98       Signal  will fail and no action will take place if one of the following
99       occur:
100
101       [EINVAL]       Sig is not a valid signal number.
102
103       [EINVAL]       An attempt is made to ignore or  supply  a  handler  for
104                      SIGKILL or SIGSTOP.
105
106       [EINVAL]       An attempt is made to ignore SIGCONT (by default SIGCONT
107                      is ignored).
108

SEE ALSO

110       kill(1), ptrace(2),  kill(2),  sigvec(2),  sigblock(2),  sigsetmask(2),
111       sigpause(2), sigstack(2), setjmp(3), tty(4)
112

NOTES (VAX-11)

114       The handler routine can be declared:
115
116           handler(sig, code, scp)
117
118       Here sig is the signal number, into which the hardware faults and traps
119       are mapped as defined below.  Code is a parameter  which  is  either  a
120       constant  as  given  below  or, for compatibility mode faults, the code
121       provided by the hardware.  Scp is a pointer to  the  struct  sigcontext
122       used  by the system to restore the process context from before the sig‐
123       nal.  Compatibility mode faults are distinguished from the other SIGILL
124       traps by having PSL_CM set in the psl.
125
126       The  following  defines  the  mapping  of hardware traps to signals and
127       codes.  All of these symbols are defined in <signal.h>:
128
129          Hardware condition                  Signal       Code
130
131       Arithmetic traps:
132          Integer overflow                    SIGFPE       FPE_INTOVF_TRAP
133          Integer division by zero            SIGFPE       FPE_INTDIV_TRAP
134          Floating overflow trap              SIGFPE       FPE_FLTOVF_TRAP
135          Floating/decimal division by zero   SIGFPE       FPE_FLTDIV_TRAP
136          Floating underflow trap             SIGFPE       FPE_FLTUND_TRAP
137          Decimal overflow trap               SIGFPE       FPE_DECOVF_TRAP
138          Subscript-range                     SIGFPE       FPE_SUBRNG_TRAP
139          Floating overflow fault             SIGFPE       FPE_FLTOVF_FAULT
140          Floating divide by zero fault       SIGFPE       FPE_FLTDIV_FAULT
141          Floating underflow fault            SIGFPE       FPE_FLTUND_FAULT
142       Length access control                  SIGSEGV
143       Protection violation                   SIGBUS
144       Reserved instruction                   SIGILL       ILL_RESAD_FAULT
145       Customer-reserved instr.               SIGEMT
146       Reserved operand                       SIGILL       ILL_PRIVIN_FAULT
147       Reserved addressing                    SIGILL       ILL_RESOP_FAULT
148       Trace pending                          SIGTRAP
149       Bpt instruction                        SIGTRAP
150       Compatibility-mode                     SIGILL       hardware supplied code
151       Chme                                   SIGSEGV
152       Chms                                   SIGSEGV
153       Chmu                                   SIGSEGV
154

NOTES (PDP-11)

156       The handler routine can be declared:
157
158           handler(sig, code, scp)
159           int sig, code;
160           struct sigcontext *scp;
161
162       Here sig is the signal number, into which the hardware faults and traps
163       are mapped as defined below.  Code is a parameter that is a constant as
164       given below.  Scp is a pointer to the sigcontext structure (defined  in
165       <signal.h>), used to restore the context from before the signal.
166
167       The  following  defines  the  mapping  of hardware traps to signals and
168       codes.  All of these symbols are defined in <signal.h>:
169
170          Hardware condition                  Signal       Code
171
172       Arithmetic traps:
173          Floating overflow trap              SIGFPE       FPE_FLTOVF_TRAP
174          Floating/decimal division by zero   SIGFPE       FPE_FLTDIV_TRAP
175          Floating underflow trap             SIGFPE       FPE_FLTUND_TRAP
176          Decimal overflow trap               SIGFPE       FPE_DECOVF_TRAP
177          Illegal return code                 SIGFPE       FPE_CRAZY
178          Bad op code                         SIGFPE       FPE_OPCODE_TRAP
179          Bad operand                         SIGFPE       FPE_OPERAND_TRAP
180          Maintenance trap                    SIGFPE       FPE_MAINT_TRAP
181       Length access control                  SIGSEGV
182       Protection violation (odd address)     SIGBUS
183       Reserved instruction                   SIGILL       ILL_RESAD_FAULT
184       Customer-reserved instr.               SIGEMT
185       Trace pending                          SIGTRAP
186       Bpt instruction                        SIGTRAP
187
188       The handler routine must save any registers it uses  and  restore  them
189       before  returning.   On  the  PDP-11, the kernel saves r0 and r1 before
190       calling the handler routine, but expect the handler to save  any  other
191       registers it uses.  The standard entry code generated by the C compiler
192       for handler routines written in C  automatically  saves  the  remaining
193       general  registers,  but  floating point registers are not saved.  As a
194       result there is currently no [standard] method for  a  handler  routine
195       written  in  C to perform floating point operations without blowing the
196       interrupted program out of the water.
197
198
199
2004th Berkeley Distribution        May 20, 1986                       SIGNAL(3C)
Impressum