1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
/* signal.h - Signal handling interface.
Copyright (C) 2008 Free Software Foundation, Inc.
Written by Neal H. Walfield <neal@gnu.org>.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
The GNU Hurd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
#define _SIGNAL_H 1
#include <stdint.h>
#include <sys/types.h>
typedef volatile int sig_atomic_t;
typedef uint64_t sigset_t;
int sigaddset (sigset_t *, int);
int sigdelset (sigset_t *, int);
int sigemptyset (sigset_t *);
int sigfillset (sigset_t *);
int sigismember (const sigset_t *, int);
/* These values are consistent with Linux. */
#define SIGRTMIN 34
#define SIGRTMAX 64
enum
{
SIGHUP = 1,
#define SIGHUP SIGHUP
SIGINT,
#define SIGINT SIGINT
SIGQUIT,
#define SIGQUIT SIGQUIT
SIGILL,
#define SIGILL SIGILL
SIGTRAP,
#define SIGTRAP SIGTRAP
SIGABRT,
#define SIGABRT SIGABRT
SIGBUS,
#define SIGBUS SIGBUS
SIGFPE,
#define SIGFPE SIGFPE
SIGKILL,
#define SIGKILL SIGKILL
SIGUSR1,
#define SIGUSR1 SIGUSR1
SIGSEGV,
#define SIGSEGV SIGSEGV
SIGUSR2,
#define SIGUSR2 SIGUSR2
SIGPIPE,
#define SIGPIPE SIGPIPE
SIGALRM,
#define SIGALRM SIGALRM
SIGTERM,
#define SIGTERM SIGTERM
SIGSTKFLT,
#define SIGSTKFLT SIGSTKFLT
SIGCHLD,
#define SIGCHLD SIGCHLD
SIGCONT,
#define SIGCONT SIGCONT
SIGSTOP,
#define SIGSTOP SIGSTOP
SIGTSTP,
#define SIGTSTP SIGTSTP
SIGTTIN,
#define SIGTTIN SIGTTIN
SIGTTOU,
#define SIGTTOU SIGTTOU
SIGURG,
#define SIGURG SIGURG
SIGXCPU,
#define SIGXCPU SIGXCPU
SIGXFSZ,
#define SIGXFSZ SIGXFSZ
SIGVTALRM,
#define SIGVTALRM SIGVTALRM
SIGPROF,
#define SIGPROF SIGPROF
SIGWINCH,
#define SIGWINCH SIGWINCH
SIGIO,
#define SIGIO SIGIO
SIGPWR,
#define SIGPWR SIGPWR
SIGSYS,
#define SIGSYS SIGSYS
NSIG
};
/* The resulting set is the union of the current set and the signal
set pointed to by the argument set. */
#define SIG_BLOCK 1
/* The resulting set is the intersection of the current set and the
complement of the signal set pointed to by the argument set. */
#define SIG_UNBLOCK 2
/* The resulting set is the signal set pointed to by the argument
set. */
#define SIG_SETMASK 3
int pthread_sigmask (int how, const sigset_t *mask, sigset_t *old);
int sigprocmask (int how, const sigset_t *restrict mask,
sigset_t *restrict old);
/* Return set of pending signals. */
int sigpending(sigset_t *set);
union sigval
{
int sival_int;
void *sival_ptr;
};
#define SIG_DFL ((void (*)(int)) (0))
#define SIG_ERR ((void (*)(int)) (-1))
#define SIG_IGN ((void (*)(int)) (1))
/* Causes signal delivery to occur on an alternate stack. */
#define SA_ONSTACK (1 << 0)
/* Do not generate SIGCHLD when children stop or stopped children
continue. */
#define SA_NOCLDSTOP (1 << 1)
/* Causes signal dispositions to be set to SIG_DFL on entry to signal
handlers. */
#define SA_RESETHAND (1 << 2)
/* Causes certain functions to become restartable. */
#define SA_RESTART (1 << 3)
/* Causes extra information to be passed to signal handlers at the
time of receipt of a signal. */
#define SA_SIGINFO (1 << 4)
/* Causes implementations not to create zombie processes on child
death. */
#define SA_NOCLDWAIT (1 << 5)
/* Causes signal not to be automatically blocked on entry to
signal handler. */
#define SA_NODEFER (1 << 6)
typedef struct
{
int si_signo;
int si_code;
int si_errno;
pid_t si_pid;
uid_t si_uid;
void *si_addr;
int si_status;
long si_band;
union sigval si_value;
} siginfo_t;
struct sigaction
{
union
{
/* Pointer to a signal-catching function or one of the macros
SIG_IGN or SIG_DFL. */
void (*sa_handler)(int);
/* Pointer to a signal-catching function. */
void (*sa_sigaction)(int, siginfo_t *, void *);
};
/* Set of signals to be blocked during execution of the signal
handling function. */
sigset_t sa_mask;
/* Special flags. */
int sa_flags;
};
int sigaction (int signo, const struct sigaction *restrict newaction,
struct sigaction *restrict oldaction);
void (*signal (int signo, void (*handler)(int)))(int);
void (*bsd_signal (int signo, void (*handler)(int)))(int);
/* Process is executing on an alternate signal stack. */
#define SS_ONSTACK (1 << 0)
/* Alternate signal stack is disabled. */
#define SS_DISABLE (1 << 1)
/* Minimum stack size for a signal handler. */
#define MINSIGSTKSZ PAGESIZE
/* Default size in bytes for the alternate signal stack. */
#define SIGSTKSZ (16 * PAGESIZE)
typedef struct
{
void *ss_sp;
size_t ss_size;
int ss_flags;
} stack_t;
int sigaltstack(const stack_t *restrict stack, stack_t *restrict old);
#include <pthread.h>
/* Send SIGNO to the process PID. */
int kill(pid_t pid, int signo);
/* Send SIGNO to the process group PG. */
int killpg(pid_t pg, int signo);
/* Send SIGNO to thread TID. */
int pthread_kill(pthread_t tid, int signo);
/* Send a signal to thread TID using SIGINFO. */
int pthread_kill_siginfo_np (pthread_t tid, siginfo_t siginfo);
/* Send SIGNO to the calling thread. */
int raise(int signo);
typedef struct sigevent
{
/* Notification type. */
int sigev_notify;
/* Signal number. */
int sigev_signo;
/* Signal value. */
union sigval sigev_value;
/* Notification function. */
void (*sigev_notify_function) (union sigval);
/* Notification attributes. */
pthread_attr_t *sigev_notify_attributes;
} sigevent_t;
enum
{
SIGEV_NONE = 0,
#define SIGEV_NONE SIGEV_NONE
SIGEV_SIGNAL,
#define SIGEV_SIGNAL SIGEV_SIGNAL
SIGEV_THREAD
#define SIGEV_THREAD SIGEV_THREAD
};
#define SIG_HOLD
int sighold (int);
int sigignore (int);
int siginterrupt (int, int);
int sigpause (int);
int sigqueue (pid_t, int, const union sigval);
int sigrelse (int);
void (*sigset (int, void (*)(int)))(int);
int sigsuspend (const sigset_t *);
/* Wait for a signal. */
int sigwait (const sigset_t *restrict set, int *restrict signo);
int sigwaitinfo (const sigset_t *restrict set, siginfo_t *restrict info);
int sigtimedwait (const sigset_t *restrict set, siginfo_t *restrict info,
const struct timespec *restrict timespec);
#endif
|