sys_sig.c revision 1.1.2.3 1 1.1.2.3 ad /* $NetBSD: sys_sig.c,v 1.1.2.3 2006/11/17 16:34:38 ad Exp $ */
2 1.1.2.1 ad
3 1.1.2.1 ad /*-
4 1.1.2.1 ad * Copyright (c) 2006 The NetBSD Foundation, Inc.
5 1.1.2.1 ad * All rights reserved.
6 1.1.2.1 ad *
7 1.1.2.3 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.3 ad * by Andrew Doran.
9 1.1.2.3 ad *
10 1.1.2.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1.2.1 ad * modification, are permitted provided that the following conditions
12 1.1.2.1 ad * are met:
13 1.1.2.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1.2.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1.2.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.2.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1.2.1 ad * documentation and/or other materials provided with the distribution.
18 1.1.2.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1.2.1 ad * must display the following acknowledgement:
20 1.1.2.1 ad * This product includes software developed by the NetBSD
21 1.1.2.1 ad * Foundation, Inc. and its contributors.
22 1.1.2.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.2.1 ad * contributors may be used to endorse or promote products derived
24 1.1.2.1 ad * from this software without specific prior written permission.
25 1.1.2.1 ad *
26 1.1.2.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.2.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.2.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.2.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.2.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.2.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.2.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.2.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.2.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.2.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.2.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1.2.1 ad */
38 1.1.2.1 ad
39 1.1.2.1 ad /*
40 1.1.2.1 ad * Copyright (c) 1982, 1986, 1989, 1991, 1993
41 1.1.2.1 ad * The Regents of the University of California. All rights reserved.
42 1.1.2.1 ad * (c) UNIX System Laboratories, Inc.
43 1.1.2.1 ad * All or some portions of this file are derived from material licensed
44 1.1.2.1 ad * to the University of California by American Telephone and Telegraph
45 1.1.2.1 ad * Co. or Unix System Laboratories, Inc. and are reproduced herein with
46 1.1.2.1 ad * the permission of UNIX System Laboratories, Inc.
47 1.1.2.1 ad *
48 1.1.2.1 ad * Redistribution and use in source and binary forms, with or without
49 1.1.2.1 ad * modification, are permitted provided that the following conditions
50 1.1.2.1 ad * are met:
51 1.1.2.1 ad * 1. Redistributions of source code must retain the above copyright
52 1.1.2.1 ad * notice, this list of conditions and the following disclaimer.
53 1.1.2.1 ad * 2. Redistributions in binary form must reproduce the above copyright
54 1.1.2.1 ad * notice, this list of conditions and the following disclaimer in the
55 1.1.2.1 ad * documentation and/or other materials provided with the distribution.
56 1.1.2.1 ad * 3. Neither the name of the University nor the names of its contributors
57 1.1.2.1 ad * may be used to endorse or promote products derived from this software
58 1.1.2.1 ad * without specific prior written permission.
59 1.1.2.1 ad *
60 1.1.2.1 ad * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 1.1.2.1 ad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 1.1.2.1 ad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 1.1.2.1 ad * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 1.1.2.1 ad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 1.1.2.1 ad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 1.1.2.1 ad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 1.1.2.1 ad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 1.1.2.1 ad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 1.1.2.1 ad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 1.1.2.1 ad * SUCH DAMAGE.
71 1.1.2.1 ad *
72 1.1.2.1 ad * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95
73 1.1.2.1 ad */
74 1.1.2.1 ad
75 1.1.2.1 ad #include <sys/cdefs.h>
76 1.1.2.3 ad __KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.1.2.3 2006/11/17 16:34:38 ad Exp $");
77 1.1.2.1 ad
78 1.1.2.1 ad #include "opt_ptrace.h"
79 1.1.2.1 ad #include "opt_compat_netbsd.h"
80 1.1.2.1 ad #include "opt_compat_netbsd32.h"
81 1.1.2.1 ad
82 1.1.2.1 ad #include <sys/param.h>
83 1.1.2.1 ad #include <sys/kernel.h>
84 1.1.2.1 ad #include <sys/malloc.h>
85 1.1.2.1 ad #include <sys/signalvar.h>
86 1.1.2.1 ad #include <sys/proc.h>
87 1.1.2.1 ad #include <sys/pool.h>
88 1.1.2.1 ad #include <sys/sa.h>
89 1.1.2.1 ad #include <sys/savar.h>
90 1.1.2.1 ad #include <sys/syscallargs.h>
91 1.1.2.1 ad #include <sys/kauth.h>
92 1.1.2.1 ad #include <sys/wait.h>
93 1.1.2.1 ad
94 1.1.2.1 ad #ifdef COMPAT_16
95 1.1.2.1 ad /* ARGSUSED */
96 1.1.2.1 ad int
97 1.1.2.1 ad compat_16_sys___sigaction14(struct lwp *l, void *v, register_t *retval)
98 1.1.2.1 ad {
99 1.1.2.1 ad struct compat_16_sys___sigaction14_args /* {
100 1.1.2.1 ad syscallarg(int) signum;
101 1.1.2.1 ad syscallarg(const struct sigaction *) nsa;
102 1.1.2.1 ad syscallarg(struct sigaction *) osa;
103 1.1.2.1 ad } */ *uap = v;
104 1.1.2.1 ad struct sigaction nsa, osa;
105 1.1.2.1 ad int error;
106 1.1.2.1 ad
107 1.1.2.1 ad if (SCARG(uap, nsa)) {
108 1.1.2.1 ad error = copyin(SCARG(uap, nsa), &nsa, sizeof(nsa));
109 1.1.2.1 ad if (error)
110 1.1.2.1 ad return (error);
111 1.1.2.1 ad }
112 1.1.2.1 ad error = sigaction1(l, SCARG(uap, signum),
113 1.1.2.1 ad SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0,
114 1.1.2.1 ad NULL, 0);
115 1.1.2.1 ad if (error)
116 1.1.2.1 ad return (error);
117 1.1.2.1 ad if (SCARG(uap, osa)) {
118 1.1.2.1 ad error = copyout(&osa, SCARG(uap, osa), sizeof(osa));
119 1.1.2.1 ad if (error)
120 1.1.2.1 ad return (error);
121 1.1.2.1 ad }
122 1.1.2.1 ad return (0);
123 1.1.2.1 ad }
124 1.1.2.1 ad #endif
125 1.1.2.1 ad
126 1.1.2.1 ad /* ARGSUSED */
127 1.1.2.1 ad int
128 1.1.2.1 ad sys___sigaction_sigtramp(struct lwp *l, void *v, register_t *retval)
129 1.1.2.1 ad {
130 1.1.2.1 ad struct sys___sigaction_sigtramp_args /* {
131 1.1.2.1 ad syscallarg(int) signum;
132 1.1.2.1 ad syscallarg(const struct sigaction *) nsa;
133 1.1.2.1 ad syscallarg(struct sigaction *) osa;
134 1.1.2.1 ad syscallarg(void *) tramp;
135 1.1.2.1 ad syscallarg(int) vers;
136 1.1.2.1 ad } */ *uap = v;
137 1.1.2.1 ad struct sigaction nsa, osa;
138 1.1.2.1 ad int error;
139 1.1.2.1 ad
140 1.1.2.1 ad if (SCARG(uap, nsa)) {
141 1.1.2.1 ad error = copyin(SCARG(uap, nsa), &nsa, sizeof(nsa));
142 1.1.2.1 ad if (error)
143 1.1.2.1 ad return (error);
144 1.1.2.1 ad }
145 1.1.2.1 ad error = sigaction1(l, SCARG(uap, signum),
146 1.1.2.1 ad SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0,
147 1.1.2.1 ad SCARG(uap, tramp), SCARG(uap, vers));
148 1.1.2.1 ad if (error)
149 1.1.2.1 ad return (error);
150 1.1.2.1 ad if (SCARG(uap, osa)) {
151 1.1.2.1 ad error = copyout(&osa, SCARG(uap, osa), sizeof(osa));
152 1.1.2.1 ad if (error)
153 1.1.2.1 ad return (error);
154 1.1.2.1 ad }
155 1.1.2.1 ad return (0);
156 1.1.2.1 ad }
157 1.1.2.1 ad
158 1.1.2.1 ad /*
159 1.1.2.1 ad * Manipulate signal mask. Note that we receive new mask, not pointer, and
160 1.1.2.1 ad * return old mask as return value; the library stub does the rest.
161 1.1.2.1 ad */
162 1.1.2.1 ad int
163 1.1.2.1 ad sys___sigprocmask14(struct lwp *l, void *v, register_t *retval)
164 1.1.2.1 ad {
165 1.1.2.1 ad struct sys___sigprocmask14_args /* {
166 1.1.2.1 ad syscallarg(int) how;
167 1.1.2.1 ad syscallarg(const sigset_t *) set;
168 1.1.2.1 ad syscallarg(sigset_t *) oset;
169 1.1.2.1 ad } */ *uap = v;
170 1.1.2.1 ad sigset_t nss, oss;
171 1.1.2.1 ad int error;
172 1.1.2.1 ad
173 1.1.2.1 ad if (SCARG(uap, set)) {
174 1.1.2.1 ad error = copyin(SCARG(uap, set), &nss, sizeof(nss));
175 1.1.2.1 ad if (error)
176 1.1.2.1 ad return (error);
177 1.1.2.1 ad }
178 1.1.2.1 ad error = sigprocmask1(l, SCARG(uap, how),
179 1.1.2.1 ad SCARG(uap, set) ? &nss : 0, SCARG(uap, oset) ? &oss : 0);
180 1.1.2.1 ad if (error)
181 1.1.2.1 ad return (error);
182 1.1.2.1 ad if (SCARG(uap, oset)) {
183 1.1.2.1 ad error = copyout(&oss, SCARG(uap, oset), sizeof(oss));
184 1.1.2.1 ad if (error)
185 1.1.2.1 ad return (error);
186 1.1.2.1 ad }
187 1.1.2.1 ad return (0);
188 1.1.2.1 ad }
189 1.1.2.1 ad
190 1.1.2.1 ad /* ARGSUSED */
191 1.1.2.1 ad int
192 1.1.2.1 ad sys___sigpending14(struct lwp *l, void *v, register_t *retval)
193 1.1.2.1 ad {
194 1.1.2.1 ad struct sys___sigpending14_args /* {
195 1.1.2.1 ad syscallarg(sigset_t *) set;
196 1.1.2.1 ad } */ *uap = v;
197 1.1.2.1 ad sigset_t ss;
198 1.1.2.1 ad
199 1.1.2.1 ad sigpending1(l, &ss);
200 1.1.2.1 ad return (copyout(&ss, SCARG(uap, set), sizeof(ss)));
201 1.1.2.1 ad }
202 1.1.2.1 ad
203 1.1.2.1 ad /*
204 1.1.2.1 ad * Suspend process until signal, providing mask to be set in the meantime.
205 1.1.2.1 ad * Note nonstandard calling convention: libc stub passes mask, not pointer,
206 1.1.2.1 ad * to save a copyin.
207 1.1.2.1 ad */
208 1.1.2.1 ad /* ARGSUSED */
209 1.1.2.1 ad int
210 1.1.2.1 ad sys___sigsuspend14(struct lwp *l, void *v, register_t *retval)
211 1.1.2.1 ad {
212 1.1.2.1 ad struct sys___sigsuspend14_args /* {
213 1.1.2.1 ad syscallarg(const sigset_t *) set;
214 1.1.2.1 ad } */ *uap = v;
215 1.1.2.1 ad sigset_t ss;
216 1.1.2.1 ad int error;
217 1.1.2.1 ad
218 1.1.2.1 ad if (SCARG(uap, set)) {
219 1.1.2.1 ad error = copyin(SCARG(uap, set), &ss, sizeof(ss));
220 1.1.2.1 ad if (error)
221 1.1.2.1 ad return (error);
222 1.1.2.1 ad }
223 1.1.2.1 ad
224 1.1.2.1 ad return (sigsuspend1(l, SCARG(uap, set) ? &ss : 0));
225 1.1.2.1 ad }
226 1.1.2.1 ad
227 1.1.2.1 ad /* ARGSUSED */
228 1.1.2.1 ad int
229 1.1.2.1 ad sys___sigaltstack14(struct lwp *l, void *v, register_t *retval)
230 1.1.2.1 ad {
231 1.1.2.1 ad struct sys___sigaltstack14_args /* {
232 1.1.2.1 ad syscallarg(const struct sigaltstack *) nss;
233 1.1.2.1 ad syscallarg(struct sigaltstack *) oss;
234 1.1.2.1 ad } */ *uap = v;
235 1.1.2.1 ad struct sigaltstack nss, oss;
236 1.1.2.1 ad int error;
237 1.1.2.1 ad
238 1.1.2.1 ad if (SCARG(uap, nss)) {
239 1.1.2.1 ad error = copyin(SCARG(uap, nss), &nss, sizeof(nss));
240 1.1.2.1 ad if (error)
241 1.1.2.1 ad return (error);
242 1.1.2.1 ad }
243 1.1.2.1 ad error = sigaltstack1(l,
244 1.1.2.1 ad SCARG(uap, nss) ? &nss : 0, SCARG(uap, oss) ? &oss : 0);
245 1.1.2.1 ad if (error)
246 1.1.2.1 ad return (error);
247 1.1.2.1 ad if (SCARG(uap, oss)) {
248 1.1.2.1 ad error = copyout(&oss, SCARG(uap, oss), sizeof(oss));
249 1.1.2.1 ad if (error)
250 1.1.2.1 ad return (error);
251 1.1.2.1 ad }
252 1.1.2.1 ad return (0);
253 1.1.2.1 ad }
254 1.1.2.1 ad
255 1.1.2.1 ad /* ARGSUSED */
256 1.1.2.1 ad int
257 1.1.2.1 ad sys_kill(struct lwp *l, void *v, register_t *retval)
258 1.1.2.1 ad {
259 1.1.2.1 ad struct sys_kill_args /* {
260 1.1.2.1 ad syscallarg(int) pid;
261 1.1.2.1 ad syscallarg(int) signum;
262 1.1.2.1 ad } */ *uap = v;
263 1.1.2.1 ad struct proc *p;
264 1.1.2.1 ad ksiginfo_t ksi;
265 1.1.2.1 ad int signum = SCARG(uap, signum);
266 1.1.2.1 ad int error;
267 1.1.2.1 ad
268 1.1.2.1 ad if ((u_int)signum >= NSIG)
269 1.1.2.1 ad return (EINVAL);
270 1.1.2.1 ad KSI_INIT(&ksi);
271 1.1.2.1 ad ksi.ksi_signo = signum;
272 1.1.2.1 ad ksi.ksi_code = SI_USER;
273 1.1.2.1 ad ksi.ksi_pid = l->l_proc->p_pid;
274 1.1.2.1 ad ksi.ksi_uid = kauth_cred_geteuid(l->l_cred);
275 1.1.2.1 ad if (SCARG(uap, pid) > 0) {
276 1.1.2.1 ad /* kill single process */
277 1.1.2.1 ad if ((p = p_find(SCARG(uap, pid), PFIND_UNLOCK_FAIL)) == NULL)
278 1.1.2.1 ad return (ESRCH);
279 1.1.2.3 ad mutex_enter(&p->p_mutex);
280 1.1.2.1 ad error = kauth_authorize_process(l->l_cred,
281 1.1.2.1 ad KAUTH_PROCESS_CANSIGNAL, p, (void *)(uintptr_t)signum,
282 1.1.2.1 ad NULL, NULL);
283 1.1.2.1 ad if (!error && signum) {
284 1.1.2.1 ad mutex_enter(&p->p_smutex);
285 1.1.2.1 ad kpsignal2(p, &ksi);
286 1.1.2.1 ad mutex_exit(&p->p_smutex);
287 1.1.2.1 ad }
288 1.1.2.3 ad mutex_exit(&p->p_mutex);
289 1.1.2.1 ad rw_exit(&proclist_lock);
290 1.1.2.1 ad return (0);
291 1.1.2.1 ad }
292 1.1.2.1 ad switch (SCARG(uap, pid)) {
293 1.1.2.1 ad case -1: /* broadcast signal */
294 1.1.2.1 ad return (killpg1(l, &ksi, 0, 1));
295 1.1.2.1 ad case 0: /* signal own process group */
296 1.1.2.1 ad return (killpg1(l, &ksi, 0, 0));
297 1.1.2.1 ad default: /* negative explicit process group */
298 1.1.2.1 ad return (killpg1(l, &ksi, -SCARG(uap, pid), 0));
299 1.1.2.1 ad }
300 1.1.2.1 ad /* NOTREACHED */
301 1.1.2.1 ad }
302 1.1.2.1 ad
303 1.1.2.1 ad /*
304 1.1.2.1 ad * Nonexistent system call-- signal process (may want to handle it). Flag
305 1.1.2.1 ad * error in case process won't see signal immediately (blocked or ignored).
306 1.1.2.1 ad *
307 1.1.2.1 ad * XXX This should not be here.
308 1.1.2.1 ad */
309 1.1.2.1 ad #ifndef PTRACE
310 1.1.2.1 ad __weak_alias(sys_ptrace, sys_nosys);
311 1.1.2.1 ad #endif
312 1.1.2.1 ad
313 1.1.2.1 ad /* ARGSUSED */
314 1.1.2.1 ad int
315 1.1.2.1 ad sys_nosys(struct lwp *l, void *v, register_t *retval)
316 1.1.2.1 ad {
317 1.1.2.1 ad
318 1.1.2.2 ad psignal(l->l_proc, SIGSYS);
319 1.1.2.1 ad return (ENOSYS);
320 1.1.2.1 ad }
321 1.1.2.1 ad
322 1.1.2.1 ad /* ARGSUSED */
323 1.1.2.1 ad int
324 1.1.2.1 ad sys_getcontext(struct lwp *l, void *v, register_t *retval)
325 1.1.2.1 ad {
326 1.1.2.1 ad struct sys_getcontext_args /* {
327 1.1.2.1 ad syscallarg(struct __ucontext *) ucp;
328 1.1.2.1 ad } */ *uap = v;
329 1.1.2.1 ad ucontext_t uc;
330 1.1.2.1 ad
331 1.1.2.1 ad getucontext(l, &uc);
332 1.1.2.1 ad
333 1.1.2.1 ad return (copyout(&uc, SCARG(uap, ucp), sizeof (*SCARG(uap, ucp))));
334 1.1.2.1 ad }
335 1.1.2.1 ad
336 1.1.2.1 ad /* ARGSUSED */
337 1.1.2.1 ad int
338 1.1.2.1 ad sys_setcontext(struct lwp *l, void *v, register_t *retval)
339 1.1.2.1 ad {
340 1.1.2.1 ad struct sys_setcontext_args /* {
341 1.1.2.1 ad syscallarg(const ucontext_t *) ucp;
342 1.1.2.1 ad } */ *uap = v;
343 1.1.2.1 ad ucontext_t uc;
344 1.1.2.1 ad int error;
345 1.1.2.1 ad
346 1.1.2.1 ad if (SCARG(uap, ucp) == NULL) { /* i.e. end of uc_link chain */
347 1.1.2.1 ad /* Acquire the sched state mutex. exit1() will release it. */
348 1.1.2.1 ad mutex_enter(&l->l_proc->p_smutex);
349 1.1.2.1 ad exit1(l, W_EXITCODE(0, 0));
350 1.1.2.1 ad } else if ((error = copyin(SCARG(uap, ucp), &uc, sizeof (uc))) != 0 ||
351 1.1.2.1 ad (error = setucontext(l, &uc)) != 0)
352 1.1.2.1 ad return (error);
353 1.1.2.1 ad
354 1.1.2.1 ad return (EJUSTRETURN);
355 1.1.2.1 ad }
356 1.1.2.1 ad
357 1.1.2.1 ad /*
358 1.1.2.1 ad * sigtimedwait(2) system call, used also for implementation
359 1.1.2.1 ad * of sigwaitinfo() and sigwait().
360 1.1.2.1 ad *
361 1.1.2.1 ad * This only handles single LWP in signal wait. libpthread provides
362 1.1.2.1 ad * it's own sigtimedwait() wrapper to DTRT WRT individual threads.
363 1.1.2.1 ad */
364 1.1.2.1 ad int
365 1.1.2.1 ad sys___sigtimedwait(struct lwp *l, void *v, register_t *retval)
366 1.1.2.1 ad {
367 1.1.2.1 ad
368 1.1.2.1 ad return __sigtimedwait1(l, v, retval, copyout, copyin, copyout);
369 1.1.2.1 ad }
370 1.1.2.1 ad
371 1.1.2.1 ad int
372 1.1.2.1 ad sigaction1(struct lwp *l, int signum, const struct sigaction *nsa,
373 1.1.2.1 ad struct sigaction *osa, const void *tramp, int vers)
374 1.1.2.1 ad {
375 1.1.2.1 ad struct proc *p;
376 1.1.2.1 ad struct sigacts *ps;
377 1.1.2.1 ad sigset_t tset;
378 1.1.2.3 ad int prop, error;
379 1.1.2.1 ad
380 1.1.2.1 ad if (signum <= 0 || signum >= NSIG)
381 1.1.2.1 ad return (EINVAL);
382 1.1.2.1 ad
383 1.1.2.1 ad p = l->l_proc;
384 1.1.2.3 ad error = 0;
385 1.1.2.1 ad
386 1.1.2.1 ad /*
387 1.1.2.1 ad * Trampoline ABI version 0 is reserved for the legacy kernel
388 1.1.2.1 ad * provided on-stack trampoline. Conversely, if we are using a
389 1.1.2.1 ad * non-0 ABI version, we must have a trampoline. Only validate the
390 1.1.2.1 ad * vers if a new sigaction was supplied. Emulations use legacy
391 1.1.2.1 ad * kernel trampolines with version 0, alternatively check for that
392 1.1.2.1 ad * too.
393 1.1.2.1 ad */
394 1.1.2.1 ad if ((vers != 0 && tramp == NULL) ||
395 1.1.2.1 ad #ifdef SIGTRAMP_VALID
396 1.1.2.1 ad (nsa != NULL &&
397 1.1.2.1 ad ((vers == 0) ?
398 1.1.2.1 ad (p->p_emul->e_sigcode == NULL) :
399 1.1.2.1 ad !SIGTRAMP_VALID(vers))) ||
400 1.1.2.1 ad #endif
401 1.1.2.1 ad (vers == 0 && tramp != NULL)) {
402 1.1.2.1 ad return (EINVAL);
403 1.1.2.1 ad }
404 1.1.2.1 ad
405 1.1.2.3 ad mutex_enter(&p->p_mutex); /* p_flag */
406 1.1.2.1 ad mutex_enter(&p->p_smutex);
407 1.1.2.3 ad
408 1.1.2.1 ad ps = p->p_sigacts;
409 1.1.2.1 ad if (osa)
410 1.1.2.1 ad *osa = SIGACTION_PS(ps, signum);
411 1.1.2.3 ad if (!nsa)
412 1.1.2.3 ad goto out;
413 1.1.2.1 ad
414 1.1.2.1 ad prop = sigprop[signum];
415 1.1.2.1 ad if ((nsa->sa_flags & ~SA_ALLBITS) || (prop & SA_CANTMASK)) {
416 1.1.2.3 ad error = EINVAL;
417 1.1.2.3 ad goto out;
418 1.1.2.1 ad }
419 1.1.2.1 ad
420 1.1.2.1 ad SIGACTION_PS(ps, signum) = *nsa;
421 1.1.2.1 ad ps->sa_sigdesc[signum].sd_tramp = tramp;
422 1.1.2.1 ad ps->sa_sigdesc[signum].sd_vers = vers;
423 1.1.2.1 ad sigminusset(&sigcantmask, &SIGACTION_PS(ps, signum).sa_mask);
424 1.1.2.1 ad
425 1.1.2.1 ad if ((prop & SA_NORESET) != 0)
426 1.1.2.1 ad SIGACTION_PS(ps, signum).sa_flags &= ~SA_RESETHAND;
427 1.1.2.1 ad
428 1.1.2.1 ad if (signum == SIGCHLD) {
429 1.1.2.1 ad if (nsa->sa_flags & SA_NOCLDSTOP)
430 1.1.2.3 ad p->p_sflag |= PS_NOCLDSTOP;
431 1.1.2.1 ad else
432 1.1.2.3 ad p->p_sflag &= ~PS_NOCLDSTOP;
433 1.1.2.1 ad if (nsa->sa_flags & SA_NOCLDWAIT) {
434 1.1.2.1 ad /*
435 1.1.2.1 ad * Paranoia: since SA_NOCLDWAIT is implemented by
436 1.1.2.1 ad * reparenting the dying child to PID 1 (and trust
437 1.1.2.1 ad * it to reap the zombie), PID 1 itself is forbidden
438 1.1.2.1 ad * to set SA_NOCLDWAIT.
439 1.1.2.1 ad */
440 1.1.2.1 ad if (p->p_pid == 1)
441 1.1.2.1 ad p->p_flag &= ~P_NOCLDWAIT;
442 1.1.2.1 ad else
443 1.1.2.1 ad p->p_flag |= P_NOCLDWAIT;
444 1.1.2.1 ad } else
445 1.1.2.1 ad p->p_flag &= ~P_NOCLDWAIT;
446 1.1.2.1 ad
447 1.1.2.1 ad if (nsa->sa_handler == SIG_IGN) {
448 1.1.2.1 ad /*
449 1.1.2.1 ad * Paranoia: same as above.
450 1.1.2.1 ad */
451 1.1.2.1 ad if (p->p_pid == 1)
452 1.1.2.1 ad p->p_flag &= ~P_CLDSIGIGN;
453 1.1.2.1 ad else
454 1.1.2.1 ad p->p_flag |= P_CLDSIGIGN;
455 1.1.2.1 ad } else
456 1.1.2.1 ad p->p_flag &= ~P_CLDSIGIGN;
457 1.1.2.1 ad }
458 1.1.2.1 ad
459 1.1.2.1 ad if ((nsa->sa_flags & SA_NODEFER) == 0)
460 1.1.2.1 ad sigaddset(&SIGACTION_PS(ps, signum).sa_mask, signum);
461 1.1.2.1 ad else
462 1.1.2.1 ad sigdelset(&SIGACTION_PS(ps, signum).sa_mask, signum);
463 1.1.2.1 ad
464 1.1.2.1 ad /*
465 1.1.2.1 ad * Set bit in p_sigctx.ps_sigignore for signals that are set to
466 1.1.2.1 ad * SIG_IGN, and for signals set to SIG_DFL where the default is to
467 1.1.2.1 ad * ignore. However, don't put SIGCONT in p_sigctx.ps_sigignore, as
468 1.1.2.1 ad * we have to restart the process.
469 1.1.2.1 ad */
470 1.1.2.1 ad if (nsa->sa_handler == SIG_IGN ||
471 1.1.2.1 ad (nsa->sa_handler == SIG_DFL && (prop & SA_IGNORE) != 0)) {
472 1.1.2.1 ad /* Never to be seen again. */
473 1.1.2.1 ad sigemptyset(&tset);
474 1.1.2.1 ad sigaddset(&tset, signum);
475 1.1.2.1 ad sigclearall(p, &tset);
476 1.1.2.1 ad if (signum != SIGCONT) {
477 1.1.2.1 ad /* Easier in psignal */
478 1.1.2.1 ad sigaddset(&p->p_sigctx.ps_sigignore, signum);
479 1.1.2.1 ad }
480 1.1.2.1 ad sigdelset(&p->p_sigctx.ps_sigcatch, signum);
481 1.1.2.1 ad } else {
482 1.1.2.1 ad sigdelset(&p->p_sigctx.ps_sigignore, signum);
483 1.1.2.1 ad if (nsa->sa_handler == SIG_DFL)
484 1.1.2.1 ad sigdelset(&p->p_sigctx.ps_sigcatch, signum);
485 1.1.2.1 ad else
486 1.1.2.1 ad sigaddset(&p->p_sigctx.ps_sigcatch, signum);
487 1.1.2.1 ad }
488 1.1.2.1 ad
489 1.1.2.1 ad /*
490 1.1.2.1 ad * Previously held signals may now have become visible. Ensure that
491 1.1.2.1 ad * we check for them before returning to userspace.
492 1.1.2.1 ad */
493 1.1.2.1 ad lwp_lock(l);
494 1.1.2.1 ad signotify(l);
495 1.1.2.1 ad lwp_unlock(l);
496 1.1.2.3 ad out:
497 1.1.2.1 ad mutex_exit(&p->p_smutex);
498 1.1.2.3 ad mutex_exit(&p->p_mutex);
499 1.1.2.3 ad
500 1.1.2.3 ad return (error);
501 1.1.2.1 ad }
502 1.1.2.1 ad
503 1.1.2.1 ad int
504 1.1.2.1 ad sigprocmask1(struct lwp *l, int how, const sigset_t *nss, sigset_t *oss)
505 1.1.2.1 ad {
506 1.1.2.1 ad struct proc *p = l->l_proc;
507 1.1.2.1 ad int more;
508 1.1.2.1 ad
509 1.1.2.1 ad mutex_enter(&p->p_smutex);
510 1.1.2.1 ad
511 1.1.2.3 ad /*
512 1.1.2.3 ad * If we've got pending signals that we haven't processed yet,
513 1.1.2.3 ad * make sure that we take them before changing the mask.
514 1.1.2.3 ad */
515 1.1.2.3 ad if (sigispending(l)) {
516 1.1.2.3 ad mutex_exit(&p->p_smutex);
517 1.1.2.3 ad return ERESTART;
518 1.1.2.3 ad }
519 1.1.2.3 ad
520 1.1.2.1 ad if (oss)
521 1.1.2.2 ad *oss = *l->l_sigmask;
522 1.1.2.1 ad if (nss) {
523 1.1.2.1 ad switch (how) {
524 1.1.2.1 ad case SIG_BLOCK:
525 1.1.2.2 ad sigplusset(nss, l->l_sigmask);
526 1.1.2.1 ad more = 0;
527 1.1.2.1 ad break;
528 1.1.2.1 ad case SIG_UNBLOCK:
529 1.1.2.2 ad sigminusset(nss, l->l_sigmask);
530 1.1.2.1 ad more = 1;
531 1.1.2.1 ad break;
532 1.1.2.1 ad case SIG_SETMASK:
533 1.1.2.2 ad *l->l_sigmask = *nss;
534 1.1.2.1 ad more = 1;
535 1.1.2.1 ad break;
536 1.1.2.1 ad default:
537 1.1.2.1 ad mutex_exit(&p->p_smutex);
538 1.1.2.1 ad return (EINVAL);
539 1.1.2.1 ad }
540 1.1.2.2 ad sigminusset(&sigcantmask, l->l_sigmask);
541 1.1.2.1 ad if (more) {
542 1.1.2.1 ad /*
543 1.1.2.3 ad * Grab signals from the per-process pending
544 1.1.2.1 ad * list that are now of interest to us.
545 1.1.2.1 ad */
546 1.1.2.2 ad if ((p->p_flag & P_SA) == 0)
547 1.1.2.2 ad sigpinch(&p->p_sigpend, l->l_sigpend,
548 1.1.2.2 ad l->l_sigmask);
549 1.1.2.1 ad
550 1.1.2.1 ad /*
551 1.1.2.1 ad * Check for pending signals on return to user.
552 1.1.2.1 ad */
553 1.1.2.1 ad lwp_lock(l);
554 1.1.2.1 ad signotify(l);
555 1.1.2.1 ad lwp_unlock(l);
556 1.1.2.1 ad }
557 1.1.2.1 ad }
558 1.1.2.1 ad
559 1.1.2.1 ad mutex_exit(&p->p_smutex);
560 1.1.2.1 ad
561 1.1.2.1 ad return (0);
562 1.1.2.1 ad }
563 1.1.2.1 ad
564 1.1.2.1 ad void
565 1.1.2.1 ad sigpending1(struct lwp *l, sigset_t *ss)
566 1.1.2.1 ad {
567 1.1.2.1 ad struct proc *p = l->l_proc;
568 1.1.2.1 ad
569 1.1.2.1 ad mutex_enter(&p->p_smutex);
570 1.1.2.2 ad *ss = l->l_sigpend->sp_set;
571 1.1.2.2 ad sigminusset(l->l_sigmask, ss);
572 1.1.2.1 ad mutex_exit(&p->p_smutex);
573 1.1.2.1 ad }
574 1.1.2.1 ad
575 1.1.2.1 ad int
576 1.1.2.1 ad sigsuspend1(struct lwp *l, const sigset_t *ss)
577 1.1.2.1 ad {
578 1.1.2.1 ad struct proc *p;
579 1.1.2.1 ad struct sigacts *ps;
580 1.1.2.1 ad
581 1.1.2.1 ad p = l->l_proc;
582 1.1.2.1 ad ps = p->p_sigacts;
583 1.1.2.1 ad
584 1.1.2.1 ad mutex_enter(&p->p_smutex);
585 1.1.2.1 ad
586 1.1.2.3 ad /*
587 1.1.2.3 ad * If we've got pending signals that we haven't processed yet,
588 1.1.2.3 ad * make sure that we take them before changing the mask.
589 1.1.2.3 ad */
590 1.1.2.3 ad if (sigispending(l)) {
591 1.1.2.3 ad mutex_exit(&p->p_smutex);
592 1.1.2.3 ad return ERESTART;
593 1.1.2.3 ad }
594 1.1.2.3 ad
595 1.1.2.1 ad if (ss) {
596 1.1.2.1 ad /*
597 1.1.2.1 ad * When returning from sigpause, we want
598 1.1.2.1 ad * the old mask to be restored after the
599 1.1.2.1 ad * signal handler has finished. Thus, we
600 1.1.2.1 ad * save it here and mark the sigctx structure
601 1.1.2.1 ad * to indicate this.
602 1.1.2.1 ad */
603 1.1.2.2 ad l->l_sigoldmask = *l->l_sigmask;
604 1.1.2.1 ad l->l_sigrestore = 1;
605 1.1.2.2 ad *l->l_sigmask = *ss;
606 1.1.2.2 ad sigminusset(&sigcantmask, l->l_sigmask);
607 1.1.2.3 ad
608 1.1.2.3 ad /*
609 1.1.2.3 ad * Pinch any signals from the per-process pending
610 1.1.2.3 ad * list that are now of interest to us.
611 1.1.2.3 ad */
612 1.1.2.3 ad if ((p->p_flag & P_SA) == 0)
613 1.1.2.3 ad sigpinch(&p->p_sigpend, l->l_sigpend, l->l_sigmask);
614 1.1.2.3 ad
615 1.1.2.1 ad lwp_lock(l);
616 1.1.2.1 ad signotify(l);
617 1.1.2.1 ad lwp_unlock(l);
618 1.1.2.1 ad }
619 1.1.2.1 ad
620 1.1.2.1 ad while (mtsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0,
621 1.1.2.1 ad &p->p_smutex) == 0)
622 1.1.2.1 ad /* void */;
623 1.1.2.1 ad
624 1.1.2.1 ad mutex_exit(&p->p_smutex);
625 1.1.2.1 ad
626 1.1.2.1 ad /* always return EINTR rather than ERESTART... */
627 1.1.2.1 ad return (EINTR);
628 1.1.2.1 ad }
629 1.1.2.1 ad
630 1.1.2.1 ad int
631 1.1.2.1 ad sigaltstack1(struct lwp *l, const struct sigaltstack *nss,
632 1.1.2.1 ad struct sigaltstack *oss)
633 1.1.2.1 ad {
634 1.1.2.2 ad struct proc *p = l->l_proc;
635 1.1.2.2 ad int error = 0;
636 1.1.2.2 ad
637 1.1.2.2 ad mutex_enter(&p->p_smutex);
638 1.1.2.1 ad
639 1.1.2.1 ad if (oss)
640 1.1.2.2 ad *oss = *l->l_sigstk;
641 1.1.2.1 ad
642 1.1.2.1 ad if (nss) {
643 1.1.2.1 ad if (nss->ss_flags & ~SS_ALLBITS)
644 1.1.2.2 ad error = EINVAL;
645 1.1.2.2 ad else if (nss->ss_flags & SS_DISABLE) {
646 1.1.2.2 ad if (l->l_sigstk->ss_flags & SS_ONSTACK)
647 1.1.2.2 ad error = EINVAL;
648 1.1.2.2 ad } else if (nss->ss_size < MINSIGSTKSZ)
649 1.1.2.2 ad error = ENOMEM;
650 1.1.2.1 ad
651 1.1.2.2 ad if (!error)
652 1.1.2.2 ad *l->l_sigstk = *nss;
653 1.1.2.1 ad }
654 1.1.2.1 ad
655 1.1.2.2 ad mutex_exit(&p->p_smutex);
656 1.1.2.2 ad
657 1.1.2.2 ad return (error);
658 1.1.2.1 ad }
659 1.1.2.1 ad
660 1.1.2.1 ad int
661 1.1.2.1 ad __sigtimedwait1(struct lwp *l, void *v, register_t *retval,
662 1.1.2.1 ad copyout_t put_info, copyin_t fetch_timeout, copyout_t put_timeout)
663 1.1.2.1 ad {
664 1.1.2.1 ad struct sys___sigtimedwait_args /* {
665 1.1.2.1 ad syscallarg(const sigset_t *) set;
666 1.1.2.1 ad syscallarg(siginfo_t *) info;
667 1.1.2.1 ad syscallarg(struct timespec *) timeout;
668 1.1.2.1 ad } */ *uap = v;
669 1.1.2.1 ad sigset_t *waitset;
670 1.1.2.1 ad struct proc *p = l->l_proc;
671 1.1.2.1 ad int error, signum;
672 1.1.2.1 ad int timo = 0;
673 1.1.2.1 ad struct timespec ts, tsstart, tsnow;
674 1.1.2.1 ad ksiginfo_t *ksi;
675 1.1.2.1 ad
676 1.1.2.1 ad memset(&tsstart, 0, sizeof tsstart); /* XXX gcc */
677 1.1.2.1 ad
678 1.1.2.1 ad /*
679 1.1.2.1 ad * Calculate timeout, if it was specified.
680 1.1.2.1 ad */
681 1.1.2.1 ad if (SCARG(uap, timeout)) {
682 1.1.2.1 ad uint64_t ms;
683 1.1.2.1 ad
684 1.1.2.1 ad if ((error = (*fetch_timeout)(SCARG(uap, timeout), &ts, sizeof(ts))))
685 1.1.2.1 ad return (error);
686 1.1.2.1 ad
687 1.1.2.1 ad ms = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
688 1.1.2.1 ad timo = mstohz(ms);
689 1.1.2.1 ad if (timo == 0 && ts.tv_sec == 0 && ts.tv_nsec > 0)
690 1.1.2.1 ad timo = 1;
691 1.1.2.1 ad if (timo <= 0)
692 1.1.2.1 ad return (EAGAIN);
693 1.1.2.1 ad
694 1.1.2.1 ad /*
695 1.1.2.1 ad * Remember current uptime, it would be used in
696 1.1.2.1 ad * ECANCELED/ERESTART case.
697 1.1.2.1 ad */
698 1.1.2.1 ad getnanouptime(&tsstart);
699 1.1.2.1 ad }
700 1.1.2.1 ad
701 1.1.2.1 ad MALLOC(waitset, sigset_t *, sizeof(sigset_t), M_TEMP, M_WAITOK);
702 1.1.2.1 ad if ((error = copyin(SCARG(uap, set), waitset, sizeof(sigset_t)))) {
703 1.1.2.1 ad FREE(waitset, M_TEMP);
704 1.1.2.1 ad return (error);
705 1.1.2.1 ad }
706 1.1.2.1 ad
707 1.1.2.1 ad /*
708 1.1.2.1 ad * Silently ignore SA_CANTMASK signals. psignal1() would ignore
709 1.1.2.1 ad * SA_CANTMASK signals in waitset, we do this only for the below
710 1.1.2.1 ad * siglist check.
711 1.1.2.1 ad */
712 1.1.2.1 ad sigminusset(&sigcantmask, waitset);
713 1.1.2.1 ad
714 1.1.2.1 ad /*
715 1.1.2.1 ad * Allocate a ksi up front. We can't sleep with the mutex held.
716 1.1.2.1 ad */
717 1.1.2.3 ad if ((ksi = ksiginfo_alloc(p, NULL, PR_WAITOK)) == NULL) {
718 1.1.2.3 ad FREE(waitset, M_TEMP);
719 1.1.2.3 ad return (ENOMEM);
720 1.1.2.3 ad }
721 1.1.2.3 ad
722 1.1.2.3 ad mutex_enter(&p->p_smutex);
723 1.1.2.1 ad
724 1.1.2.1 ad /*
725 1.1.2.3 ad * If we've got pending signals that we haven't processed yet,
726 1.1.2.3 ad * make sure that we take them before changing the mask.
727 1.1.2.1 ad */
728 1.1.2.3 ad if ((error = sigispending(l)) != 0) {
729 1.1.2.3 ad mutex_exit(&p->p_smutex);
730 1.1.2.3 ad goto out;
731 1.1.2.3 ad }
732 1.1.2.1 ad
733 1.1.2.2 ad /*
734 1.1.2.2 ad * SA processes can have no more than 1 sigwaiter.
735 1.1.2.2 ad */
736 1.1.2.2 ad if ((p->p_flag & P_SA) != 0 && !LIST_EMPTY(&p->p_sigwaiters)) {
737 1.1.2.2 ad mutex_exit(&p->p_smutex);
738 1.1.2.2 ad error = EINVAL;
739 1.1.2.2 ad goto out;
740 1.1.2.2 ad }
741 1.1.2.2 ad
742 1.1.2.1 ad if ((signum = sigget(&p->p_sigpend, ksi, 0, waitset)) == 0)
743 1.1.2.2 ad if ((p->p_flag & P_SA) == 0)
744 1.1.2.2 ad signum = sigget(l->l_sigpend, ksi, 0, waitset);
745 1.1.2.1 ad
746 1.1.2.1 ad if (signum != 0) {
747 1.1.2.1 ad /*
748 1.1.2.1 ad * We found a pending signal - copy it out to the user.
749 1.1.2.1 ad */
750 1.1.2.1 ad mutex_exit(&p->p_smutex);
751 1.1.2.2 ad goto out;
752 1.1.2.1 ad }
753 1.1.2.1 ad
754 1.1.2.1 ad /*
755 1.1.2.1 ad * Set up the sigwait list. Pass pointer to malloced memory here;
756 1.1.2.1 ad * it's not possible to pass pointer to a structure on current
757 1.1.2.1 ad * process's stack, the current LWP might be swapped out when the
758 1.1.2.1 ad * when the signal is delivered.
759 1.1.2.1 ad */
760 1.1.2.1 ad l->l_sigwaited = ksi;
761 1.1.2.1 ad l->l_sigwait = waitset;
762 1.1.2.2 ad LIST_INSERT_HEAD(&p->p_sigwaiters, l, l_sigwaiter);
763 1.1.2.1 ad
764 1.1.2.1 ad /*
765 1.1.2.1 ad * Wait for signal to arrive. We can either be woken up or time out.
766 1.1.2.1 ad */
767 1.1.2.1 ad error = mtsleep(&l->l_sigwait, PPAUSE|PCATCH, "sigwait", timo,
768 1.1.2.1 ad &p->p_smutex);
769 1.1.2.1 ad
770 1.1.2.1 ad /*
771 1.1.2.1 ad * Need to find out if we woke as a result of lwp_wakeup() or a
772 1.1.2.1 ad * signal outside our wait set.
773 1.1.2.1 ad */
774 1.1.2.1 ad if (l->l_sigwaited != NULL) {
775 1.1.2.1 ad if (error == EINTR) {
776 1.1.2.1 ad /* wakeup via _lwp_wakeup() */
777 1.1.2.1 ad error = ECANCELED;
778 1.1.2.1 ad } else if (!error) {
779 1.1.2.1 ad /* spurious wakeup - arrange for syscall restart */
780 1.1.2.1 ad error = ERESTART;
781 1.1.2.1 ad }
782 1.1.2.1 ad }
783 1.1.2.1 ad
784 1.1.2.1 ad /*
785 1.1.2.1 ad * Clear the sigwait indication and unlock.
786 1.1.2.1 ad */
787 1.1.2.1 ad l->l_sigwait = NULL;
788 1.1.2.1 ad l->l_sigwaited = NULL;
789 1.1.2.2 ad LIST_REMOVE(l, l_sigwaiter);
790 1.1.2.1 ad mutex_exit(&p->p_smutex);
791 1.1.2.1 ad
792 1.1.2.1 ad /*
793 1.1.2.1 ad * If the sleep was interrupted (either by signal or wakeup), update
794 1.1.2.1 ad * the timeout and copyout new value back. It would be used when
795 1.1.2.1 ad * the syscall would be restarted or called again.
796 1.1.2.1 ad */
797 1.1.2.1 ad if (timo && (error == ERESTART || error == ECANCELED)) {
798 1.1.2.1 ad getnanouptime(&tsnow);
799 1.1.2.1 ad
800 1.1.2.1 ad /* compute how much time has passed since start */
801 1.1.2.1 ad timespecsub(&tsnow, &tsstart, &tsnow);
802 1.1.2.1 ad /* substract passed time from timeout */
803 1.1.2.1 ad timespecsub(&ts, &tsnow, &ts);
804 1.1.2.1 ad
805 1.1.2.1 ad if (ts.tv_sec < 0)
806 1.1.2.1 ad error = EAGAIN;
807 1.1.2.1 ad else {
808 1.1.2.1 ad /* copy updated timeout to userland */
809 1.1.2.1 ad error = (*put_timeout)(&ts, SCARG(uap, timeout),
810 1.1.2.1 ad sizeof(ts));
811 1.1.2.1 ad }
812 1.1.2.1 ad }
813 1.1.2.1 ad
814 1.1.2.1 ad /*
815 1.1.2.1 ad * If a signal from the wait set arrived, copy it to userland.
816 1.1.2.1 ad * Copy only the used part of siginfo, the padding part is
817 1.1.2.1 ad * left unchanged (userland is not supposed to touch it anyway).
818 1.1.2.1 ad */
819 1.1.2.2 ad out:
820 1.1.2.1 ad FREE(waitset, M_TEMP);
821 1.1.2.3 ad ksiginfo_free(ksi);
822 1.1.2.1 ad
823 1.1.2.1 ad if (error == 0)
824 1.1.2.1 ad error = (*put_info)(&ksi->ksi_info, SCARG(uap, info),
825 1.1.2.1 ad sizeof(ksi->ksi_info));
826 1.1.2.1 ad
827 1.1.2.1 ad return error;
828 1.1.2.1 ad }
829