source: trunk/minix/man/man2/sigaction.2@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 5.2 KB
Line 
1.TH SIGACTION 2
2.SH NAME
3sigaction, signal \- manage signal state and handlers
4.SH SYNOPSIS
5.ft B
6#include <signal.h>
7
8.in +5
9.ti -5
10int sigaction(int \fIsig\fP, const struct sigaction *\fIact\fP, struct sigaction *\fIoact\fP)
11.in -5
12.br
13void (*signal(int \fIsig\fP, void (*\fIhandler\fP)(int)))(int);
14.ft P
15.SH DESCRIPTION
16.de SP
17.if t .sp 0.4
18.if n .sp
19..
20.B Sigaction()
21is used to examine, set, or modify the attributes of a signal. The argument
22.I sig
23is the signal in question. The
24.I act
25argument points to a structure containing the new attributes of the signal,
26the structure pointed to by
27.I oact
28will receive the old attributes that were in effect before the call.
29.PP
30The
31.I act
32and
33.I oact
34arguments may be
35.B NULL
36to indicate that either no new attributes are to be set, or that the old
37attributes are not of interest.
38.PP
39The structure containing the signal attributes is defined in <signal.h> and
40looks like this:
41.PP
42.RS
43.nf
44.ft B
45.ta +4n +12n
46struct sigaction {
47 void (*sa_handler)(int sig);
48 sigset_t sa_mask;
49 int sa_flags;
50};
51.ft R
52.fi
53.RE
54.PP
55The
56.B sa_handler
57field contains the address of a signal handler, a function that is called
58when the process is signalled, or one of these special constants:
59.PP
60.TP 12
61.B SIG_DFL
62Default signal handling is to be performed. This usually means that the
63process is killed, but some signals may be ignored by default.
64.TP
65.B SIG_IGN
66Ignore the signal.
67.PP
68The
69.B sa_mask
70field indicates a set of signals that must be blocked when the signal is
71being handled. Whether the signal
72.I sig
73itself is blocked when being handled is not controlled by this mask. The
74mask is of a "signal set" type that is to be manipulated by the
75.BR sigset (3)
76functions.
77.PP
78How the signal is handled precisely is specified by bits in
79.BR sa_flags .
80If none of the flags is set then the handler is called when the signal
81arrives. The signal is blocked during the call to the handler, and
82unblocked when the handler returns. A system call that is interrupted
83returns
84.B \-1
85with
86.B errno
87set to
88.BR EINTR .
89The following bit flags can be set to modify this behaviour:
90.PP
91.TP 15
92.B SA_RESETHAND
93Reset the signal handler to
94.B SIG_DFL
95when the signal is caught.
96.TP
97.B SA_NODEFER
98Do not block the signal on entry to the handler.
99.TP
100.B SA_COMPAT
101Handle the signal in a way that is compatible with the the old
102.B signal()
103call.
104.PP
105The old
106.B signal()
107signal system call sets a signal handler for a given signal and returns the
108old signal handler. No signals are blocked, the flags are
109.BR "SA_RESETHAND | SA_NODEFER | SA_COMPAT" .
110New code should not use
111.BR signal() .
112Note that
113.B signal()
114and all of the
115.B SA_*
116flags are MINIX 3 extensions.
117.PP
118Signal handlers are reset to
119.B SIG_DFL
120on an
121.BR execve (2).
122Signals that are ignored stay ignored.
123.SS Signals
124MINIX 3 knows about the following signals:
125.PP
126.nf
127.ta +11n +7n +8n
128signal num notes description
129.SP
130SIGHUP 1 k Hangup
131SIGINT 2 k Interrupt (usually DEL or CTRL\-C)
132SIGQUIT 3 kc Quit (usually CTRL\-\e)
133SIGILL 4 kc Illegal instruction
134SIGTRAP 5 xkc Trace trap
135SIGABRT 6 kc Abort program
136SIGFPE 8 k Floating point exception
137SIGKILL 9 k Kill
138SIGUSR1 10 k User defined signal #1
139SIGSEGV 11 kc Segmentation fault
140SIGUSR2 12 k User defined signal #2
141SIGPIPE 13 k Write to a pipe with no reader
142SIGALRM 14 k Alarm clock
143SIGTERM 15 k Terminate (default for kill(1))
144SIGCHLD 17 pvi Child process terminated
145SIGCONT 18 p Continue if stopped
146SIGSTOP 19 ps Stop signal
147SIGTSTP 20 ps Interactive stop signal
148SIGTTIN 21 ps Background read
149SIGTTOU 22 ps Background write
150SIGWINCH 23 xvi Window size change
151.ft R
152.fi
153.PP
154The letters in the notes column indicate:
155.PP
156.TP 5
157.B k
158The process is killed if the signal is not caught.
159.TP
160.B c
161The signal causes a core dump.
162.TP
163.B i
164The signal is ignored if not caught.
165.TP
166.B v
167Only Minix-vmd implements this signal.
168.TP
169.B x
170MINIX 3 extension, not defined by \s-2POSIX\s+2.
171.TP
172.B p
173These signals are not implemented, but \s-2POSIX\s+2 requires that they are
174defined.
175.TP
176.B s
177The process should be stopped, but is killed instead.
178.PP
179The
180.B SIGKILL
181signal cannot be caught or ignored. The
182.B SIGILL
183and
184.B SIGTRAP
185signals cannot be automatically reset. The system silently enforces these
186restrictions. This may or may not be reflected by the attributes of these
187signals and the signal masks.
188.SS Types
189\s-2POSIX\s+2 prescribes that <sys/types.h> has the following definition:
190.PP
191.RS
192.B "typedef int (*sighandler_t)(int)"
193.RE
194.PP
195With this type the following declarations can be made:
196.PP
197.RS
198.ft B
199.nf
200sighandler_t sa_handler;
201sighandler_t signal(int \fIsig\fP, sighandler_t \fIhandler\fP);
202.fi
203.ft R
204.RE
205.PP
206This may help you to understand the earlier declarations better. The
207.B sighandler_t
208type is also very useful in old style C code that is compiled by a compiler
209for standard C.
210.SH "SEE ALSO"
211.BR kill (1),
212.BR kill (2),
213.BR pause (2),
214.BR sigprocmask (2),
215.BR sigsuspend (2),
216.BR sigpending (2),
217.BR sigset (3).
218.SH DIAGNOSTICS
219.B Sigaction()
220returns
221.B 0
222on success or
223.B \-1
224on error.
225.B Signal()
226returns the old handler on success or
227.B SIG_ERR
228on error. The error code may be:
229.PP
230.TP 10
231.B EINVAL
232Bad signal number.
233.TP
234.B EFAULT
235Bad
236.I act
237or
238.I oact
239addresses.
240.SH AUTHOR
241Kees J. Bot (kjb@cs.vu.nl)
242
243.\"
244.\" $PchId: sigaction.2,v 1.2 1996/04/11 06:00:28 philip Exp $
Note: See TracBrowser for help on using the repository browser.