linux_signal.c revision 1.5 1 1.5 christos /* $NetBSD: linux_signal.c,v 1.5 1995/06/24 20:20:30 christos Exp $ */
2 1.1 fvdl
3 1.1 fvdl /*
4 1.1 fvdl * Copyright (c) 1995 Frank van der Linden
5 1.1 fvdl * All rights reserved.
6 1.1 fvdl *
7 1.1 fvdl * Redistribution and use in source and binary forms, with or without
8 1.1 fvdl * modification, are permitted provided that the following conditions
9 1.1 fvdl * are met:
10 1.1 fvdl * 1. Redistributions of source code must retain the above copyright
11 1.1 fvdl * notice, this list of conditions and the following disclaimer.
12 1.1 fvdl * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 fvdl * notice, this list of conditions and the following disclaimer in the
14 1.1 fvdl * documentation and/or other materials provided with the distribution.
15 1.1 fvdl * 3. All advertising materials mentioning features or use of this software
16 1.1 fvdl * must display the following acknowledgement:
17 1.1 fvdl * This product includes software developed for the NetBSD Project
18 1.1 fvdl * by Frank van der Linden
19 1.1 fvdl * 4. The name of the author may not be used to endorse or promote products
20 1.1 fvdl * derived from this software without specific prior written permission
21 1.1 fvdl *
22 1.1 fvdl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 fvdl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 fvdl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 fvdl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 fvdl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 fvdl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 fvdl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 fvdl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 fvdl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 fvdl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 fvdl *
33 1.1 fvdl * heavily from: svr4_signal.c,v 1.7 1995/01/09 01:04:21 christos Exp
34 1.1 fvdl */
35 1.1 fvdl
36 1.1 fvdl #include <sys/param.h>
37 1.1 fvdl #include <sys/systm.h>
38 1.1 fvdl #include <sys/namei.h>
39 1.1 fvdl #include <sys/proc.h>
40 1.1 fvdl #include <sys/filedesc.h>
41 1.1 fvdl #include <sys/ioctl.h>
42 1.1 fvdl #include <sys/mount.h>
43 1.1 fvdl #include <sys/kernel.h>
44 1.1 fvdl #include <sys/signal.h>
45 1.1 fvdl #include <sys/signalvar.h>
46 1.1 fvdl #include <sys/malloc.h>
47 1.1 fvdl
48 1.1 fvdl #include <sys/syscallargs.h>
49 1.1 fvdl
50 1.1 fvdl #include <compat/linux/linux_types.h>
51 1.1 fvdl #include <compat/linux/linux_syscallargs.h>
52 1.1 fvdl #include <compat/linux/linux_util.h>
53 1.1 fvdl #include <compat/linux/linux_signal.h>
54 1.1 fvdl
55 1.1 fvdl /*
56 1.3 fvdl * Most of ths stuff in this file is taken from Christos' SVR4 emul
57 1.1 fvdl * code. The things that need to be done are largely the same, so
58 1.1 fvdl * re-inventing the wheel doesn't make much sense.
59 1.1 fvdl */
60 1.1 fvdl
61 1.1 fvdl /*
62 1.1 fvdl * Some boring signal conversion functions. Just a switch() for all signals;
63 1.1 fvdl * return the converted signal number, 0 if not supported.
64 1.1 fvdl */
65 1.1 fvdl
66 1.1 fvdl int
67 1.1 fvdl bsd_to_linux_sig(sig)
68 1.1 fvdl int sig;
69 1.1 fvdl {
70 1.1 fvdl switch(sig) {
71 1.1 fvdl case SIGHUP:
72 1.1 fvdl return LINUX_SIGHUP;
73 1.1 fvdl case SIGINT:
74 1.1 fvdl return LINUX_SIGINT;
75 1.1 fvdl case SIGQUIT:
76 1.1 fvdl return LINUX_SIGQUIT;
77 1.1 fvdl case SIGILL:
78 1.1 fvdl return LINUX_SIGILL;
79 1.1 fvdl case SIGTRAP:
80 1.1 fvdl return LINUX_SIGTRAP;
81 1.1 fvdl case SIGABRT:
82 1.1 fvdl return LINUX_SIGABRT;
83 1.1 fvdl case SIGFPE:
84 1.1 fvdl return LINUX_SIGFPE;
85 1.1 fvdl case SIGKILL:
86 1.1 fvdl return LINUX_SIGKILL;
87 1.1 fvdl case SIGBUS:
88 1.1 fvdl return LINUX_SIGBUS;
89 1.1 fvdl case SIGSEGV:
90 1.1 fvdl return LINUX_SIGSEGV;
91 1.1 fvdl case SIGPIPE:
92 1.1 fvdl return LINUX_SIGPIPE;
93 1.1 fvdl case SIGALRM:
94 1.1 fvdl return LINUX_SIGALRM;
95 1.1 fvdl case SIGTERM:
96 1.1 fvdl return LINUX_SIGTERM;
97 1.1 fvdl case SIGURG:
98 1.1 fvdl return LINUX_SIGURG;
99 1.1 fvdl case SIGSTOP:
100 1.1 fvdl return LINUX_SIGSTOP;
101 1.1 fvdl case SIGTSTP:
102 1.1 fvdl return LINUX_SIGTSTP;
103 1.1 fvdl case SIGCONT:
104 1.1 fvdl return LINUX_SIGCONT;
105 1.1 fvdl case SIGCHLD:
106 1.1 fvdl return LINUX_SIGCHLD;
107 1.1 fvdl case SIGTTIN:
108 1.1 fvdl return LINUX_SIGTTIN;
109 1.1 fvdl case SIGTTOU:
110 1.1 fvdl return LINUX_SIGTTOU;
111 1.1 fvdl case SIGIO:
112 1.1 fvdl return LINUX_SIGIO;
113 1.1 fvdl case SIGXCPU:
114 1.1 fvdl return LINUX_SIGXCPU;
115 1.1 fvdl case SIGXFSZ:
116 1.1 fvdl return LINUX_SIGXFSZ;
117 1.1 fvdl case SIGVTALRM:
118 1.1 fvdl return LINUX_SIGVTALRM;
119 1.1 fvdl case SIGPROF:
120 1.1 fvdl return LINUX_SIGPROF;
121 1.1 fvdl case SIGWINCH:
122 1.1 fvdl return LINUX_SIGWINCH;
123 1.1 fvdl case SIGUSR1:
124 1.1 fvdl return LINUX_SIGUSR1;
125 1.1 fvdl case SIGUSR2:
126 1.1 fvdl return LINUX_SIGUSR2;
127 1.1 fvdl /* Not supported: EMT, SYS, INFO */
128 1.1 fvdl }
129 1.1 fvdl return 0;
130 1.1 fvdl }
131 1.1 fvdl
132 1.1 fvdl int
133 1.1 fvdl linux_to_bsd_sig(sig)
134 1.1 fvdl int sig;
135 1.1 fvdl {
136 1.1 fvdl switch(sig) {
137 1.1 fvdl case LINUX_SIGHUP:
138 1.1 fvdl return SIGHUP;
139 1.1 fvdl case LINUX_SIGINT:
140 1.1 fvdl return SIGINT;
141 1.1 fvdl case LINUX_SIGQUIT:
142 1.1 fvdl return SIGQUIT;
143 1.1 fvdl case LINUX_SIGILL:
144 1.1 fvdl return SIGILL;
145 1.1 fvdl case LINUX_SIGTRAP:
146 1.1 fvdl return SIGTRAP;
147 1.1 fvdl case LINUX_SIGABRT:
148 1.1 fvdl return SIGABRT;
149 1.1 fvdl case LINUX_SIGBUS:
150 1.1 fvdl return SIGBUS;
151 1.1 fvdl case LINUX_SIGFPE:
152 1.1 fvdl return SIGFPE;
153 1.1 fvdl case LINUX_SIGKILL:
154 1.1 fvdl return SIGKILL;
155 1.1 fvdl case LINUX_SIGUSR1:
156 1.1 fvdl return SIGUSR1;
157 1.1 fvdl case LINUX_SIGSEGV:
158 1.1 fvdl return SIGSEGV;
159 1.1 fvdl case LINUX_SIGUSR2:
160 1.1 fvdl return SIGUSR2;
161 1.1 fvdl case LINUX_SIGPIPE:
162 1.1 fvdl return SIGPIPE;
163 1.1 fvdl case LINUX_SIGALRM:
164 1.1 fvdl return SIGALRM;
165 1.1 fvdl case LINUX_SIGTERM:
166 1.1 fvdl return SIGTERM;
167 1.1 fvdl case LINUX_SIGCHLD:
168 1.1 fvdl return SIGCHLD;
169 1.1 fvdl case LINUX_SIGCONT:
170 1.1 fvdl return SIGCONT;
171 1.1 fvdl case LINUX_SIGSTOP:
172 1.1 fvdl return SIGSTOP;
173 1.1 fvdl case LINUX_SIGTSTP:
174 1.1 fvdl return SIGTSTP;
175 1.1 fvdl case LINUX_SIGTTIN:
176 1.1 fvdl return SIGTTIN;
177 1.1 fvdl case LINUX_SIGTTOU:
178 1.1 fvdl return SIGTTOU;
179 1.1 fvdl case LINUX_SIGURG:
180 1.1 fvdl return SIGURG;
181 1.1 fvdl case LINUX_SIGXCPU:
182 1.1 fvdl return SIGXCPU;
183 1.1 fvdl case LINUX_SIGXFSZ:
184 1.1 fvdl return SIGXFSZ;
185 1.1 fvdl case LINUX_SIGVTALRM:
186 1.1 fvdl return SIGVTALRM;
187 1.1 fvdl case LINUX_SIGPROF:
188 1.1 fvdl return SIGPROF;
189 1.1 fvdl case LINUX_SIGWINCH:
190 1.1 fvdl return SIGWINCH;
191 1.1 fvdl case LINUX_SIGIO:
192 1.1 fvdl return SIGIO;
193 1.1 fvdl /* Not supported: STKFLT, PWR */
194 1.1 fvdl }
195 1.1 fvdl return 0;
196 1.1 fvdl }
197 1.1 fvdl
198 1.1 fvdl /*
199 1.1 fvdl * Ok, we know that Linux and BSD signals both are just an unsigned int.
200 1.1 fvdl * Don't bother to use the sigismember() stuff for now.
201 1.1 fvdl */
202 1.1 fvdl static void
203 1.1 fvdl linux_to_bsd_sigset(lss, bss)
204 1.1 fvdl const linux_sigset_t *lss;
205 1.1 fvdl sigset_t *bss;
206 1.1 fvdl {
207 1.1 fvdl int i, newsig;
208 1.1 fvdl
209 1.1 fvdl *bss = (sigset_t) 0;
210 1.1 fvdl for (i = 1; i <= LINUX_NSIG; i++) {
211 1.1 fvdl if (*lss & sigmask(i)) {
212 1.1 fvdl newsig = linux_to_bsd_sig(i);
213 1.1 fvdl if (newsig)
214 1.1 fvdl *bss |= sigmask(newsig);
215 1.1 fvdl }
216 1.1 fvdl }
217 1.1 fvdl }
218 1.1 fvdl
219 1.1 fvdl void
220 1.1 fvdl bsd_to_linux_sigset(bss, lss)
221 1.1 fvdl const sigset_t *bss;
222 1.1 fvdl linux_sigset_t *lss;
223 1.1 fvdl {
224 1.1 fvdl int i, newsig;
225 1.1 fvdl
226 1.1 fvdl *lss = (linux_sigset_t) 0;
227 1.1 fvdl for (i = 1; i <= NSIG; i++) {
228 1.1 fvdl if (*bss & sigmask(i)) {
229 1.1 fvdl newsig = bsd_to_linux_sig(i);
230 1.1 fvdl if (newsig)
231 1.1 fvdl *lss |= sigmask(newsig);
232 1.1 fvdl }
233 1.1 fvdl }
234 1.1 fvdl }
235 1.1 fvdl
236 1.1 fvdl /*
237 1.1 fvdl * Convert between Linux and BSD sigaction structures. Linux has
238 1.1 fvdl * one extra field (sa_restorer) which we don't support. The Linux
239 1.1 fvdl * SA_ONESHOT and SA_NOMASK flags (which together form the old
240 1.1 fvdl * SysV signal behavior) are silently ignored. XXX
241 1.1 fvdl */
242 1.1 fvdl void
243 1.1 fvdl linux_to_bsd_sigaction(lsa, bsa)
244 1.1 fvdl struct linux_sigaction *lsa;
245 1.1 fvdl struct sigaction *bsa;
246 1.1 fvdl {
247 1.1 fvdl bsa->sa_handler = lsa->sa_handler;
248 1.1 fvdl linux_to_bsd_sigset(&bsa->sa_mask, &lsa->sa_mask);
249 1.1 fvdl bsa->sa_flags = 0;
250 1.1 fvdl bsa->sa_flags |= cvtto_bsd_mask(lsa->sa_flags, LINUX_SA_NOCLDSTOP,
251 1.1 fvdl SA_NOCLDSTOP);
252 1.1 fvdl bsa->sa_flags |= cvtto_bsd_mask(lsa->sa_flags, LINUX_SA_ONSTACK,
253 1.1 fvdl SA_ONSTACK);
254 1.1 fvdl bsa->sa_flags |= cvtto_bsd_mask(lsa->sa_flags, LINUX_SA_RESTART,
255 1.1 fvdl SA_RESTART);
256 1.1 fvdl }
257 1.1 fvdl
258 1.1 fvdl void
259 1.1 fvdl bsd_to_linux_sigaction(bsa, lsa)
260 1.1 fvdl struct sigaction *bsa;
261 1.1 fvdl struct linux_sigaction *lsa;
262 1.1 fvdl {
263 1.1 fvdl lsa->sa_handler = bsa->sa_handler;
264 1.1 fvdl bsd_to_linux_sigset(&lsa->sa_mask, &bsa->sa_mask);
265 1.1 fvdl lsa->sa_flags = 0;
266 1.1 fvdl lsa->sa_flags |= cvtto_linux_mask(bsa->sa_flags, SA_NOCLDSTOP,
267 1.1 fvdl LINUX_SA_NOCLDSTOP);
268 1.1 fvdl lsa->sa_flags |= cvtto_linux_mask(bsa->sa_flags, SA_ONSTACK,
269 1.1 fvdl LINUX_SA_ONSTACK);
270 1.1 fvdl lsa->sa_flags |= cvtto_linux_mask(bsa->sa_flags, SA_RESTART,
271 1.1 fvdl LINUX_SA_RESTART);
272 1.1 fvdl lsa->sa_restorer = NULL;
273 1.1 fvdl }
274 1.1 fvdl
275 1.1 fvdl
276 1.1 fvdl /*
277 1.1 fvdl * The Linux sigaction() system call. Do the usual conversions,
278 1.1 fvdl * and just call sigaction(). Some flags and values are silently
279 1.1 fvdl * ignored (see above).
280 1.1 fvdl */
281 1.1 fvdl int
282 1.1 fvdl linux_sigaction(p, uap, retval)
283 1.1 fvdl register struct proc *p;
284 1.1 fvdl struct linux_sigaction_args /* {
285 1.1 fvdl syscallarg(int) signum;
286 1.1 fvdl syscallarg(struct linux_sigaction *) nsa;
287 1.1 fvdl syscallarg(struct linux_sigaction *) osa;
288 1.1 fvdl } */ *uap;
289 1.1 fvdl register_t *retval;
290 1.1 fvdl {
291 1.1 fvdl struct sigaction *nbsda = NULL, *obsda = NULL, tmpbsda;
292 1.1 fvdl struct linux_sigaction *nlsa, *olsa, tmplsa;
293 1.1 fvdl struct sigaction_args sa;
294 1.1 fvdl caddr_t sg;
295 1.1 fvdl int error;
296 1.1 fvdl
297 1.5 christos sg = stackgap_init(p->p_emul);
298 1.1 fvdl olsa = SCARG(uap, osa);
299 1.1 fvdl nlsa = SCARG(uap, nsa);
300 1.1 fvdl
301 1.1 fvdl if (olsa != NULL)
302 1.1 fvdl obsda = stackgap_alloc(&sg, sizeof (struct sigaction));
303 1.1 fvdl
304 1.1 fvdl if (nlsa != NULL) {
305 1.1 fvdl nbsda = stackgap_alloc(&sg, sizeof (struct sigaction));
306 1.1 fvdl if ((error = copyin(nlsa, &tmplsa, sizeof tmplsa)))
307 1.1 fvdl return error;
308 1.1 fvdl linux_to_bsd_sigaction(&tmplsa, &tmpbsda);
309 1.1 fvdl if ((error = copyout(&tmpbsda, nbsda, sizeof tmpbsda)))
310 1.1 fvdl return error;
311 1.1 fvdl }
312 1.1 fvdl
313 1.1 fvdl SCARG(&sa, signum) = linux_to_bsd_sig(SCARG(uap, signum));
314 1.1 fvdl SCARG(&sa, nsa) = nbsda;
315 1.1 fvdl SCARG(&sa, osa) = obsda;
316 1.1 fvdl
317 1.1 fvdl if ((error = sigaction(p, &sa, retval)))
318 1.1 fvdl return error;
319 1.1 fvdl
320 1.1 fvdl if (olsa != NULL) {
321 1.1 fvdl if ((error = copyin(obsda, &tmpbsda, sizeof tmpbsda)))
322 1.1 fvdl return error;
323 1.1 fvdl bsd_to_linux_sigaction(&tmpbsda, &tmplsa);
324 1.1 fvdl if ((error = copyout(&tmplsa, olsa, sizeof tmplsa)))
325 1.1 fvdl return error;
326 1.1 fvdl }
327 1.1 fvdl return 0;
328 1.1 fvdl }
329 1.1 fvdl
330 1.1 fvdl /*
331 1.1 fvdl * The Linux signal() system call. I think that the signal() in the C
332 1.1 fvdl * library actually calls sigaction, so I doubt this one is ever used.
333 1.1 fvdl * But hey, it can't hurt having it here. The same restrictions as for
334 1.1 fvdl * sigaction() apply.
335 1.1 fvdl */
336 1.1 fvdl int
337 1.1 fvdl linux_signal(p, uap, retval)
338 1.1 fvdl register struct proc *p;
339 1.1 fvdl struct linux_signal_args /* {
340 1.1 fvdl syscallarg(int) sig;
341 1.1 fvdl syscallarg(linux_handler_t) handler;
342 1.1 fvdl } */ *uap;
343 1.1 fvdl register_t *retval;
344 1.1 fvdl {
345 1.1 fvdl caddr_t sg;
346 1.1 fvdl struct sigaction_args sa_args;
347 1.1 fvdl struct sigaction *osa, *nsa, tmpsa;
348 1.1 fvdl int error;
349 1.1 fvdl
350 1.5 christos sg = stackgap_init(p->p_emul);
351 1.1 fvdl nsa = stackgap_alloc(&sg, sizeof *nsa);
352 1.1 fvdl osa = stackgap_alloc(&sg, sizeof *osa);
353 1.1 fvdl
354 1.1 fvdl tmpsa.sa_handler = SCARG(uap, handler);
355 1.1 fvdl tmpsa.sa_mask = (sigset_t) 0;
356 1.1 fvdl tmpsa.sa_flags = 0;
357 1.1 fvdl if ((error = copyout(&tmpsa, nsa, sizeof tmpsa)))
358 1.1 fvdl return error;
359 1.1 fvdl
360 1.1 fvdl SCARG(&sa_args, signum) = linux_to_bsd_sig(SCARG(uap, sig));
361 1.1 fvdl SCARG(&sa_args, osa) = osa;
362 1.1 fvdl SCARG(&sa_args, nsa) = nsa;
363 1.1 fvdl if ((error = sigaction(p, &sa_args, retval)))
364 1.1 fvdl return error;
365 1.1 fvdl
366 1.1 fvdl if ((error = copyin(osa, &tmpsa, sizeof *osa)))
367 1.1 fvdl return error;
368 1.1 fvdl retval[0] = (register_t) tmpsa.sa_handler;
369 1.1 fvdl
370 1.1 fvdl return 0;
371 1.1 fvdl }
372 1.1 fvdl
373 1.1 fvdl /*
374 1.1 fvdl * This is just a copy of the svr4 compat one. I feel so creative now.
375 1.1 fvdl */
376 1.1 fvdl int
377 1.1 fvdl linux_sigprocmask(p, uap, retval)
378 1.1 fvdl register struct proc *p;
379 1.1 fvdl register struct linux_sigprocmask_args /* {
380 1.1 fvdl syscallarg(int) how;
381 1.1 fvdl syscallarg(linux_sigset_t *) set;
382 1.1 fvdl syscallarg(linux_sigset_t * oset;
383 1.1 fvdl } */ *uap;
384 1.1 fvdl register_t *retval;
385 1.1 fvdl {
386 1.1 fvdl linux_sigset_t ss;
387 1.1 fvdl sigset_t bs;
388 1.1 fvdl int error = 0;
389 1.1 fvdl
390 1.1 fvdl *retval = 0;
391 1.1 fvdl
392 1.1 fvdl if (SCARG(uap, oset) != NULL) {
393 1.1 fvdl /* Fix the return value first if needed */
394 1.1 fvdl bsd_to_linux_sigset(&p->p_sigmask, &ss);
395 1.1 fvdl if ((error = copyout(&ss, SCARG(uap, oset), sizeof(ss))) != 0)
396 1.1 fvdl return error;
397 1.1 fvdl }
398 1.1 fvdl
399 1.1 fvdl if (SCARG(uap, set) == NULL)
400 1.1 fvdl /* Just examine */
401 1.1 fvdl return 0;
402 1.1 fvdl
403 1.1 fvdl if ((error = copyin(SCARG(uap, set), &ss, sizeof(ss))) != 0)
404 1.1 fvdl return error;
405 1.1 fvdl
406 1.1 fvdl linux_to_bsd_sigset(&ss, &bs);
407 1.1 fvdl
408 1.1 fvdl (void) splhigh();
409 1.1 fvdl
410 1.1 fvdl switch (SCARG(uap, how)) {
411 1.1 fvdl case LINUX_SIG_BLOCK:
412 1.1 fvdl p->p_sigmask |= bs & ~sigcantmask;
413 1.1 fvdl break;
414 1.1 fvdl
415 1.1 fvdl case LINUX_SIG_UNBLOCK:
416 1.1 fvdl p->p_sigmask &= ~bs;
417 1.1 fvdl break;
418 1.1 fvdl
419 1.1 fvdl case LINUX_SIG_SETMASK:
420 1.1 fvdl p->p_sigmask = bs & ~sigcantmask;
421 1.1 fvdl break;
422 1.1 fvdl
423 1.1 fvdl default:
424 1.1 fvdl error = EINVAL;
425 1.1 fvdl break;
426 1.1 fvdl }
427 1.1 fvdl
428 1.1 fvdl (void) spl0();
429 1.1 fvdl
430 1.1 fvdl return error;
431 1.1 fvdl }
432 1.1 fvdl
433 1.1 fvdl /*
434 1.1 fvdl * The functions below really make no distinction between an int
435 1.1 fvdl * and [linux_]sigset_t. This is ok for now, but it might break
436 1.1 fvdl * sometime. Then again, sigset_t is trusted to be an int everywhere
437 1.1 fvdl * else in the kernel too.
438 1.1 fvdl */
439 1.1 fvdl /* ARGSUSED */
440 1.1 fvdl int
441 1.1 fvdl linux_siggetmask(p, uap, retval)
442 1.1 fvdl struct proc *p;
443 1.1 fvdl void *uap;
444 1.1 fvdl register_t *retval;
445 1.1 fvdl {
446 1.1 fvdl bsd_to_linux_sigset(&p->p_sigmask, (linux_sigset_t *) retval);
447 1.1 fvdl return 0;
448 1.1 fvdl }
449 1.1 fvdl
450 1.1 fvdl /*
451 1.1 fvdl * The following three functions fiddle with a process' signal mask.
452 1.1 fvdl * Convert the signal masks because of the different signal
453 1.1 fvdl * values for Linux. The need for this is the reason why
454 1.1 fvdl * they are here, and have not been mapped directly.
455 1.1 fvdl */
456 1.1 fvdl int
457 1.1 fvdl linux_sigsetmask(p, uap, retval)
458 1.1 fvdl struct proc *p;
459 1.1 fvdl struct linux_sigsetmask_args /* {
460 1.1 fvdl syscallarg(linux_sigset_t) mask;
461 1.1 fvdl } */ *uap;
462 1.1 fvdl register_t *retval;
463 1.1 fvdl {
464 1.1 fvdl linux_sigset_t mask;
465 1.1 fvdl sigset_t bsdsig;
466 1.1 fvdl
467 1.1 fvdl bsd_to_linux_sigset(&p->p_sigmask, (linux_sigset_t *) retval);
468 1.1 fvdl
469 1.1 fvdl mask = SCARG(uap, mask);
470 1.1 fvdl bsd_to_linux_sigset(&mask, &bsdsig);
471 1.1 fvdl
472 1.1 fvdl splhigh();
473 1.1 fvdl p->p_sigmask = bsdsig & ~sigcantmask;
474 1.1 fvdl spl0();
475 1.1 fvdl
476 1.1 fvdl return 0;
477 1.1 fvdl }
478 1.1 fvdl
479 1.1 fvdl int
480 1.1 fvdl linux_sigpending(p, uap, retval)
481 1.1 fvdl struct proc *p;
482 1.1 fvdl struct linux_sigpending_args /* {
483 1.1 fvdl syscallarg(linux_sigset_t *) mask;
484 1.1 fvdl } */ *uap;
485 1.1 fvdl register_t *retval;
486 1.1 fvdl {
487 1.1 fvdl sigset_t bsdsig;
488 1.1 fvdl linux_sigset_t linuxsig;
489 1.1 fvdl
490 1.1 fvdl bsdsig = p->p_siglist & p->p_sigmask;
491 1.1 fvdl
492 1.1 fvdl bsd_to_linux_sigset(&bsdsig, &linuxsig);
493 1.1 fvdl return copyout(&linuxsig, SCARG(uap, mask), sizeof linuxsig);
494 1.1 fvdl }
495 1.1 fvdl
496 1.1 fvdl int
497 1.1 fvdl linux_sigsuspend(p, uap, retval)
498 1.1 fvdl struct proc *p;
499 1.1 fvdl struct linux_sigsuspend_args /* {
500 1.3 fvdl syscallarg(caddr_t) restart;
501 1.3 fvdl syscallarg(int) oldmask;
502 1.1 fvdl syscallarg(int) mask;
503 1.1 fvdl } */ *uap;
504 1.1 fvdl register_t *retval;
505 1.1 fvdl {
506 1.1 fvdl struct sigsuspend_args ssa;
507 1.1 fvdl
508 1.1 fvdl linux_to_bsd_sigset(&SCARG(uap, mask), &SCARG(&ssa, mask));
509 1.1 fvdl return sigsuspend(p, &ssa, retval);
510 1.3 fvdl }
511 1.3 fvdl
512 1.3 fvdl /*
513 1.3 fvdl * The deprecated pause(2), which is really just an instance
514 1.3 fvdl * of sigsuspend(2).
515 1.3 fvdl */
516 1.3 fvdl int
517 1.3 fvdl linux_pause(p, uap, retval)
518 1.3 fvdl struct proc *p;
519 1.3 fvdl void *uap;
520 1.3 fvdl register_t *retval;
521 1.3 fvdl {
522 1.3 fvdl struct sigsuspend_args bsa;
523 1.3 fvdl
524 1.3 fvdl SCARG(&bsa, mask) = p->p_sigmask;
525 1.3 fvdl return sigsuspend(p, &bsa, retval);
526 1.1 fvdl }
527 1.1 fvdl
528 1.1 fvdl /*
529 1.1 fvdl * Once more: only a signal conversion is needed.
530 1.1 fvdl */
531 1.1 fvdl int
532 1.1 fvdl linux_kill(p, uap, retval)
533 1.1 fvdl struct proc *p;
534 1.1 fvdl struct linux_kill_args /* {
535 1.1 fvdl syscallarg(int) pid;
536 1.1 fvdl syscallarg(int) signum;
537 1.1 fvdl } */ *uap;
538 1.1 fvdl register_t *retval;
539 1.1 fvdl {
540 1.1 fvdl SCARG(uap, signum) = linux_to_bsd_sig(SCARG(uap, signum));
541 1.1 fvdl return kill(p, (struct kill_args *) uap, retval);
542 1.1 fvdl }
543