1146329Skeramida/*	$NetBSD: sys_sig.c,v 1.17 2008/10/15 06:51:20 wrstuden Exp $	*/
2146329Skeramida
3146329Skeramida/*-
4146329Skeramida * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
5146329Skeramida * All rights reserved.
6146329Skeramida *
7146329Skeramida * This code is derived from software contributed to The NetBSD Foundation
8146329Skeramida * by Andrew Doran.
9146329Skeramida *
10146329Skeramida * Redistribution and use in source and binary forms, with or without
11146329Skeramida * modification, are permitted provided that the following conditions
12146329Skeramida * are met:
13146329Skeramida * 1. Redistributions of source code must retain the above copyright
14146329Skeramida *    notice, this list of conditions and the following disclaimer.
15146329Skeramida * 2. Redistributions in binary form must reproduce the above copyright
16146329Skeramida *    notice, this list of conditions and the following disclaimer in the
17146329Skeramida *    documentation and/or other materials provided with the distribution.
18146329Skeramida *
19146329Skeramida * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20146329Skeramida * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21146329Skeramida * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22146329Skeramida * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23146329Skeramida * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24146329Skeramida * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25146329Skeramida * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26146329Skeramida * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27204166Sgavin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28146329Skeramida * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29146329Skeramida * POSSIBILITY OF SUCH DAMAGE.
30146329Skeramida */
31146329Skeramida
32146329Skeramida/*
33146329Skeramida * Copyright (c) 1982, 1986, 1989, 1991, 1993
34146329Skeramida *	The Regents of the University of California.  All rights reserved.
35146329Skeramida * (c) UNIX System Laboratories, Inc.
36146329Skeramida * All or some portions of this file are derived from material licensed
37146329Skeramida * to the University of California by American Telephone and Telegraph
38146329Skeramida * Co. or Unix System Laboratories, Inc. and are reproduced herein with
39146329Skeramida * the permission of UNIX System Laboratories, Inc.
40146329Skeramida *
41146329Skeramida * Redistribution and use in source and binary forms, with or without
42146329Skeramida * modification, are permitted provided that the following conditions
43146329Skeramida * are met:
44146329Skeramida * 1. Redistributions of source code must retain the above copyright
45146329Skeramida *    notice, this list of conditions and the following disclaimer.
46146329Skeramida * 2. Redistributions in binary form must reproduce the above copyright
47146329Skeramida *    notice, this list of conditions and the following disclaimer in the
48146329Skeramida *    documentation and/or other materials provided with the distribution.
49146329Skeramida * 3. Neither the name of the University nor the names of its contributors
50146329Skeramida *    may be used to endorse or promote products derived from this software
51146329Skeramida *    without specific prior written permission.
52146329Skeramida *
53146329Skeramida * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54147432Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55146329Skeramida * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56146329Skeramida * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57146329Skeramida * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58146329Skeramida * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59146329Skeramida * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60146329Skeramida * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61146329Skeramida * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62146329Skeramida * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63155048Skeramida * SUCH DAMAGE.
64155048Skeramida *
65155048Skeramida *	@(#)kern_sig.c	8.14 (Berkeley) 5/14/95
66155048Skeramida */
67155048Skeramida
68155048Skeramida#include <sys/cdefs.h>
69155048Skeramida__KERNEL_RCSID(0, "$NetBSD: sys_sig.c,v 1.17 2008/10/15 06:51:20 wrstuden Exp $");
70155048Skeramida
71155181Sjoel#include <sys/param.h>
72155048Skeramida#include <sys/kernel.h>
73155048Skeramida#include <sys/signalvar.h>
74155048Skeramida#include <sys/proc.h>
75155048Skeramida#include <sys/pool.h>
76155048Skeramida#include <sys/sa.h>
77155048Skeramida#include <sys/savar.h>
78155048Skeramida#include <sys/syscallargs.h>
79155048Skeramida#include <sys/kauth.h>
80155048Skeramida#include <sys/wait.h>
81155048Skeramida#include <sys/kmem.h>
82155048Skeramida
83155048Skeramida/* ARGSUSED */
84147432Sruint
85236278Sgjbcompat_16_sys___sigaction14(struct lwp *l, const struct compat_16_sys___sigaction14_args *uap, register_t *retval)
86204166Sgavin{
87204166Sgavin	/* {
88204166Sgavin		syscallarg(int)				signum;
89204166Sgavin		syscallarg(const struct sigaction *)	nsa;
90147432Sru		syscallarg(struct sigaction *)		osa;
91204166Sgavin	} */
92204166Sgavin	struct sigaction	nsa, osa;
93204166Sgavin	int			error;
94204166Sgavin
95204166Sgavin	if (SCARG(uap, nsa)) {
96147432Sru		error = copyin(SCARG(uap, nsa), &nsa, sizeof(nsa));
97146329Skeramida		if (error)
98146329Skeramida			return (error);
99146329Skeramida	}
100146329Skeramida	error = sigaction1(l, SCARG(uap, signum),
101146329Skeramida	    SCARG(uap, nsa) ? &nsa : 0, SCARG(uap, osa) ? &osa : 0,
102146329Skeramida	    NULL, 0);
103146329Skeramida	if (error)
104155048Skeramida		return (error);
105147432Sru	if (SCARG(uap, osa)) {
106147432Sru		error = copyout(&osa, SCARG(uap, osa), sizeof(osa));
107155048Skeramida		if (error)
108155048Skeramida			return (error);
109155048Skeramida	}
110155048Skeramida	return (0);
111202024Sthompsa}
112202024Sthompsa