root / prex-0.9.0 / include / sys / signal.h @ 03e9c04a
History | View | Annotate | Download (6.62 KB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
3 |
* The Regents of the University of California. All rights reserved.
|
4 |
* (c) UNIX System Laboratories, Inc.
|
5 |
* All or some portions of this file are derived from material licensed
|
6 |
* to the University of California by American Telephone and Telegraph
|
7 |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
8 |
* the permission of UNIX System Laboratories, Inc.
|
9 |
*
|
10 |
* Redistribution and use in source and binary forms, with or without
|
11 |
* modification, are permitted provided that the following conditions
|
12 |
* are met:
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
14 |
* notice, this list of conditions and the following disclaimer.
|
15 |
* 2. Redistributions in binary form must reproduce the above copyright
|
16 |
* notice, this list of conditions and the following disclaimer in the
|
17 |
* documentation and/or other materials provided with the distribution.
|
18 |
* 3. Neither the name of the University nor the names of its contributors
|
19 |
* may be used to endorse or promote products derived from this software
|
20 |
* without specific prior written permission.
|
21 |
*
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
23 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
26 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
27 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
28 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
30 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
31 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
32 |
* SUCH DAMAGE.
|
33 |
*
|
34 |
* @(#)signal.h 8.4 (Berkeley) 5/4/95
|
35 |
*/
|
36 |
|
37 |
#ifndef _SYS_SIGNAL_H_
|
38 |
#define _SYS_SIGNAL_H_
|
39 |
|
40 |
#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ |
41 |
|
42 |
#include <machine/signal.h> /* sigcontext */ |
43 |
|
44 |
#define SIGHUP 1 /* hangup */ |
45 |
#define SIGINT 2 /* interrupt */ |
46 |
#define SIGQUIT 3 /* quit */ |
47 |
#define SIGILL 4 /* illegal instruction (not reset when caught) */ |
48 |
#define SIGTRAP 5 /* trace trap (not reset when caught) */ |
49 |
#define SIGABRT 6 /* abort() */ |
50 |
#define SIGIOT SIGABRT /* compatibility */ |
51 |
#define SIGEMT 7 /* EMT instruction */ |
52 |
#define SIGFPE 8 /* floating point exception */ |
53 |
#define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
54 |
#define SIGBUS 10 /* bus error */ |
55 |
#define SIGSEGV 11 /* segmentation violation */ |
56 |
#define SIGSYS 12 /* bad argument to system call */ |
57 |
#define SIGPIPE 13 /* write on a pipe with no one to read it */ |
58 |
#define SIGALRM 14 /* alarm clock */ |
59 |
#define SIGTERM 15 /* software termination signal from kill */ |
60 |
#define SIGURG 16 /* urgent condition on IO channel */ |
61 |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
62 |
#define SIGTSTP 18 /* stop signal from tty */ |
63 |
#define SIGCONT 19 /* continue a stopped process */ |
64 |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
65 |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
66 |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
67 |
#define SIGIO 23 /* input/output possible signal */ |
68 |
#define SIGXCPU 24 /* exceeded CPU time limit */ |
69 |
#define SIGXFSZ 25 /* exceeded file size limit */ |
70 |
#define SIGVTALRM 26 /* virtual time alarm */ |
71 |
#define SIGPROF 27 /* profiling time alarm */ |
72 |
#define SIGWINCH 28 /* window size changes */ |
73 |
#define SIGINFO 29 /* information request */ |
74 |
#define SIGPWR SIGINFO
|
75 |
#define SIGUSR1 30 /* user defined signal 1 */ |
76 |
#define SIGUSR2 31 /* user defined signal 2 */ |
77 |
|
78 |
#ifndef KERNEL
|
79 |
|
80 |
/*
|
81 |
* Language spec sez we must list exactly one parameter, even though we
|
82 |
* actually supply three. Ugh!
|
83 |
*/
|
84 |
#define SIG_DFL ((void (*)(int)) 0) |
85 |
#define SIG_IGN ((void (*)(int)) 1) |
86 |
#define SIG_ERR ((void (*)(int)) -1) |
87 |
|
88 |
typedef unsigned int sigset_t; |
89 |
|
90 |
union sigval {
|
91 |
int sival_int;
|
92 |
void *sival_ptr;
|
93 |
}; |
94 |
|
95 |
struct siginfo {
|
96 |
int si_signo; /* redundant signal number */ |
97 |
int si_code; /* facility that raised this signal */ |
98 |
union sigval si_value; /* value that was queued with signal */ |
99 |
}; |
100 |
|
101 |
typedef struct siginfo siginfo_t; |
102 |
|
103 |
/*
|
104 |
* Signal vector "template" used in sigaction call.
|
105 |
*/
|
106 |
struct sigaction {
|
107 |
union {
|
108 |
void (*__sa_handler) (int); |
109 |
void (*__sa_sigaction) (int, siginfo_t *, void *); |
110 |
} __sigaction_u; |
111 |
sigset_t sa_mask; |
112 |
int sa_flags;
|
113 |
}; |
114 |
|
115 |
#define sa_handler __sigaction_u.__sa_handler
|
116 |
#define sa_sigaction __sigaction_u.__sa_sigaction
|
117 |
|
118 |
/* sa_flags bits */
|
119 |
|
120 |
#define SA_ONSTACK 0x0001 /* take signal on signal stack */ |
121 |
#define SA_RESTART 0x0002 /* restart system on signal return */ |
122 |
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */ |
123 |
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ |
124 |
#define SA_SIGINFO 0x0040 /* take sa_sigaction handler */ |
125 |
|
126 |
/*
|
127 |
* Flags for sigprocmask:
|
128 |
*/
|
129 |
#define SIG_BLOCK 1 /* block specified signal set */ |
130 |
#define SIG_UNBLOCK 2 /* unblock specified signal set */ |
131 |
#define SIG_SETMASK 3 /* set specified signal set */ |
132 |
|
133 |
#include <sys/cdefs.h> |
134 |
|
135 |
typedef void (*sig_t)(int); /* type of signal function */ |
136 |
|
137 |
/*
|
138 |
* Structure used in sigaltstack call.
|
139 |
*/
|
140 |
struct sigaltstack {
|
141 |
char *ss_base; /* signal stack base */ |
142 |
int ss_size; /* signal stack length */ |
143 |
int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ |
144 |
}; |
145 |
#define MINSIGSTKSZ 8192 /* minimum allowable stack */ |
146 |
#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ |
147 |
|
148 |
/*
|
149 |
* 4.3 compatibility:
|
150 |
* Signal vector "template" used in sigvec call.
|
151 |
*/
|
152 |
struct sigvec {
|
153 |
void (*sv_handler)(int); /* signal handler */ |
154 |
int sv_mask; /* signal mask to apply */ |
155 |
int sv_flags; /* see signal options below */ |
156 |
}; |
157 |
|
158 |
#define SV_ONSTACK SA_ONSTACK
|
159 |
#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ |
160 |
#define sv_onstack sv_flags /* isn't compatibility wonderful! */ |
161 |
|
162 |
/*
|
163 |
* Structure used in sigstack call.
|
164 |
*/
|
165 |
struct sigstack {
|
166 |
char *ss_sp; /* signal stack pointer */ |
167 |
int ss_onstack; /* current status */ |
168 |
}; |
169 |
|
170 |
/*
|
171 |
* Macro for converting signal number to a mask suitable for
|
172 |
* sigblock().
|
173 |
*/
|
174 |
#define sigmask(m) (1 << ((m)-1)) |
175 |
|
176 |
#define BADSIG SIG_ERR
|
177 |
|
178 |
#ifdef _REENTRANT
|
179 |
extern mutex_t __sig_lock;
|
180 |
#define SIGNAL_LOCK() mutex_lock(&__sig_lock)
|
181 |
#define SIGNAL_UNLOCK() mutex_unlock(&__sig_lock)
|
182 |
#else
|
183 |
#define SIGNAL_LOCK()
|
184 |
#define SIGNAL_UNLOCK()
|
185 |
#endif
|
186 |
|
187 |
extern struct sigaction __sig_act[NSIG]; |
188 |
extern sigset_t __sig_mask;
|
189 |
extern sigset_t __sig_pending;
|
190 |
|
191 |
/*
|
192 |
* For historical reasons; programs expect signal's return value to be
|
193 |
* defined by <sys/signal.h>.
|
194 |
*/
|
195 |
__BEGIN_DECLS |
196 |
void (*signal(int, void (*)(int)))(int); |
197 |
int __sig_flush(void); |
198 |
__END_DECLS |
199 |
|
200 |
#endif /* !KERNEL */ |
201 |
#endif /* !_SYS_SIGNAL_H_ */ |