Home | History | Annotate | Line # | Download | only in common
linux_signal.c revision 1.16
      1  1.16      fvdl /*	$NetBSD: linux_signal.c,v 1.16 1998/10/04 00:02:42 fvdl Exp $	*/
      2  1.16      fvdl /*-
      3  1.16      fvdl  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
      4   1.1      fvdl  * All rights reserved.
      5   1.1      fvdl  *
      6  1.16      fvdl  * This code is derived from software contributed to The NetBSD Foundation
      7  1.16      fvdl  * by Frank van der Linden and Eric Haszlakiewicz.
      8  1.16      fvdl  *
      9   1.1      fvdl  * Redistribution and use in source and binary forms, with or without
     10   1.1      fvdl  * modification, are permitted provided that the following conditions
     11   1.1      fvdl  * are met:
     12   1.1      fvdl  * 1. Redistributions of source code must retain the above copyright
     13   1.1      fvdl  *    notice, this list of conditions and the following disclaimer.
     14   1.1      fvdl  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1      fvdl  *    notice, this list of conditions and the following disclaimer in the
     16   1.1      fvdl  *    documentation and/or other materials provided with the distribution.
     17   1.1      fvdl  * 3. All advertising materials mentioning features or use of this software
     18   1.1      fvdl  *    must display the following acknowledgement:
     19  1.16      fvdl  *	This product includes software developed by the NetBSD
     20  1.16      fvdl  *	Foundation, Inc. and its contributors.
     21  1.16      fvdl  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22  1.16      fvdl  *    contributors may be used to endorse or promote products derived
     23  1.16      fvdl  *    from this software without specific prior written permission.
     24   1.1      fvdl  *
     25  1.16      fvdl  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26  1.16      fvdl  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  1.16      fvdl  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  1.16      fvdl  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29  1.16      fvdl  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  1.16      fvdl  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  1.16      fvdl  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  1.16      fvdl  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  1.16      fvdl  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  1.16      fvdl  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  1.16      fvdl  * POSSIBILITY OF SUCH DAMAGE.
     36  1.16      fvdl  */
     37  1.16      fvdl /*
     38   1.1      fvdl  * heavily from: svr4_signal.c,v 1.7 1995/01/09 01:04:21 christos Exp
     39   1.1      fvdl  */
     40   1.1      fvdl 
     41  1.14       erh /*
     42  1.14       erh  *   Functions in multiarch:
     43  1.14       erh  *	linux_sys_signal	: linux_sig_notalpha.c
     44  1.14       erh  *	linux_sys_siggetmask	: linux_sig_notalpha.c
     45  1.14       erh  *	linux_sys_sigsetmask	: linux_sig_notalpha.c
     46  1.14       erh  *	linux_sys_pause		: linux_sig_notalpha.c
     47  1.14       erh  *	linux_sys_sigaction	: linux_sigaction.c
     48  1.14       erh  *
     49  1.14       erh  */
     50  1.14       erh 
     51  1.14       erh /*
     52  1.14       erh  *   Unimplemented:
     53  1.14       erh  *	linux_sys_rt_sigtimedwait	: sigsuspend w/timeout.
     54  1.14       erh  */
     55  1.14       erh 
     56   1.1      fvdl #include <sys/param.h>
     57   1.1      fvdl #include <sys/systm.h>
     58   1.1      fvdl #include <sys/namei.h>
     59   1.1      fvdl #include <sys/proc.h>
     60   1.1      fvdl #include <sys/filedesc.h>
     61   1.1      fvdl #include <sys/ioctl.h>
     62   1.1      fvdl #include <sys/mount.h>
     63   1.1      fvdl #include <sys/kernel.h>
     64   1.1      fvdl #include <sys/signal.h>
     65   1.1      fvdl #include <sys/signalvar.h>
     66   1.1      fvdl #include <sys/malloc.h>
     67   1.1      fvdl 
     68   1.1      fvdl #include <sys/syscallargs.h>
     69   1.1      fvdl 
     70  1.15  christos #include <compat/linux/common/linux_types.h>
     71  1.15  christos #include <compat/linux/common/linux_signal.h>
     72  1.15  christos #include <compat/linux/common/linux_util.h>
     73  1.15  christos 
     74   1.1      fvdl #include <compat/linux/linux_syscallargs.h>
     75   1.1      fvdl 
     76  1.14       erh /* Locally used defines (in bsd<->linux conversion functions): */
     77  1.14       erh /* XXX XAX rename to linux_old.  Add stuff for new type linux_sigset_t
     78  1.14       erh 	handle _NSIG_WORDS > 1 */
     79   1.6   mycroft #define	linux_sigmask(n)	(1 << ((n) - 1))
     80  1.11     perry #define	linux_sigemptyset(s)	memset((s), 0, sizeof(*(s)))
     81   1.6   mycroft #define	linux_sigismember(s, n)	(*(s) & linux_sigmask(n))
     82   1.6   mycroft #define	linux_sigaddset(s, n)	(*(s) |= linux_sigmask(n))
     83   1.6   mycroft 
     84  1.14       erh /* Note: linux_to_native_sig[] is in <arch>/linux_sigarray.c */
     85  1.12   mycroft int native_to_linux_sig[NSIG] = {
     86   1.6   mycroft 	0,
     87   1.6   mycroft 	LINUX_SIGHUP,
     88   1.6   mycroft 	LINUX_SIGINT,
     89   1.6   mycroft 	LINUX_SIGQUIT,
     90   1.6   mycroft 	LINUX_SIGILL,
     91   1.6   mycroft 	LINUX_SIGTRAP,
     92   1.6   mycroft 	LINUX_SIGABRT,
     93  1.12   mycroft 	0,			/* SIGEMT */
     94   1.6   mycroft 	LINUX_SIGFPE,
     95   1.6   mycroft 	LINUX_SIGKILL,
     96   1.6   mycroft 	LINUX_SIGBUS,
     97   1.6   mycroft 	LINUX_SIGSEGV,
     98  1.12   mycroft 	0,			/* SIGSEGV */
     99   1.6   mycroft 	LINUX_SIGPIPE,
    100   1.6   mycroft 	LINUX_SIGALRM,
    101   1.6   mycroft 	LINUX_SIGTERM,
    102   1.6   mycroft 	LINUX_SIGURG,
    103   1.6   mycroft 	LINUX_SIGSTOP,
    104   1.6   mycroft 	LINUX_SIGTSTP,
    105   1.6   mycroft 	LINUX_SIGCONT,
    106   1.6   mycroft 	LINUX_SIGCHLD,
    107   1.6   mycroft 	LINUX_SIGTTIN,
    108   1.6   mycroft 	LINUX_SIGTTOU,
    109   1.6   mycroft 	LINUX_SIGIO,
    110   1.6   mycroft 	LINUX_SIGXCPU,
    111   1.6   mycroft 	LINUX_SIGXFSZ,
    112   1.6   mycroft 	LINUX_SIGVTALRM,
    113   1.6   mycroft 	LINUX_SIGPROF,
    114   1.6   mycroft 	LINUX_SIGWINCH,
    115  1.12   mycroft 	0,			/* SIGINFO */
    116   1.6   mycroft 	LINUX_SIGUSR1,
    117   1.6   mycroft 	LINUX_SIGUSR2,
    118  1.12   mycroft 	LINUX_SIGPWR,
    119   1.6   mycroft };
    120   1.6   mycroft 
    121  1.14       erh /*
    122  1.14       erh  * Ok, we know that Linux and BSD signals both are just an unsigned int.
    123  1.14       erh  * Don't bother to use the sigismember() stuff for now.
    124  1.14       erh  */
    125   1.6   mycroft void
    126  1.14       erh linux_old_to_native_sigset(lss, bss)
    127  1.14       erh 	const linux_old_sigset_t *lss;
    128   1.1      fvdl 	sigset_t *bss;
    129   1.1      fvdl {
    130   1.1      fvdl 	int i, newsig;
    131   1.1      fvdl 
    132   1.6   mycroft 	sigemptyset(bss);
    133   1.6   mycroft 	for (i = 1; i < LINUX_NSIG; i++) {
    134   1.6   mycroft 		if (linux_sigismember(lss, i)) {
    135  1.12   mycroft 			newsig = linux_to_native_sig[i];
    136   1.1      fvdl 			if (newsig)
    137   1.6   mycroft 				sigaddset(bss, newsig);
    138   1.1      fvdl 		}
    139   1.1      fvdl 	}
    140   1.1      fvdl }
    141   1.1      fvdl 
    142   1.1      fvdl void
    143  1.14       erh native_to_linux_old_sigset(bss, lss)
    144   1.1      fvdl 	const sigset_t *bss;
    145  1.14       erh 	linux_old_sigset_t *lss;
    146   1.1      fvdl {
    147   1.1      fvdl 	int i, newsig;
    148   1.1      fvdl 
    149   1.6   mycroft 	linux_sigemptyset(lss);
    150   1.6   mycroft 	for (i = 1; i < NSIG; i++) {
    151   1.6   mycroft 		if (sigismember(bss, i)) {
    152  1.12   mycroft 			newsig = native_to_linux_sig[i];
    153   1.1      fvdl 			if (newsig)
    154   1.6   mycroft 				linux_sigaddset(lss, newsig);
    155   1.1      fvdl 		}
    156   1.1      fvdl 	}
    157   1.1      fvdl }
    158   1.1      fvdl 
    159   1.1      fvdl /*
    160  1.14       erh  * Convert between Linux and BSD sigaction structures. Linux sometimes
    161  1.14       erh  * has one extra field (sa_restorer) which we don't support.
    162   1.1      fvdl  */
    163   1.1      fvdl void
    164  1.14       erh linux_old_to_native_sigaction(lsa, bsa)
    165  1.14       erh 	struct linux_old_sigaction *lsa;
    166  1.14       erh 	struct sigaction *bsa;
    167  1.14       erh {
    168  1.14       erh 
    169  1.14       erh 	bsa->sa_handler = lsa->sa_handler;
    170  1.14       erh 	linux_old_to_native_sigset(&lsa->sa_mask, &bsa->sa_mask);
    171  1.14       erh 	bsa->sa_flags = 0;
    172  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_NOCLDSTOP) != 0)
    173  1.14       erh 		bsa->sa_flags |= SA_NOCLDSTOP;
    174  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_ONSTACK) != 0)
    175  1.14       erh 		bsa->sa_flags |= SA_ONSTACK;
    176  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_RESTART) != 0)
    177  1.14       erh 		bsa->sa_flags |= SA_RESTART;
    178  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_ONESHOT) != 0)
    179  1.14       erh 		bsa->sa_flags |= SA_RESETHAND;
    180  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_NOMASK) != 0)
    181  1.14       erh 		bsa->sa_flags |= SA_NODEFER;
    182  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_SIGINFO) != 0)
    183  1.14       erh 		bsa->sa_flags |= SA_SIGINFO;
    184  1.14       erh #ifdef DEBUG
    185  1.14       erh 	if ((lsa->sa_flags & ~LINUX_SA_ALLBITS) != 0)
    186  1.14       erh /*XXX*/		printf("linux_old_to_native_sigaction: extra bits ignored\n");
    187  1.14       erh 	if (lsa->sa_restorer != 0)
    188  1.14       erh /*XXX*/		printf("linux_old_to_native_sigaction: sa_restorer ignored\n");
    189  1.14       erh #endif
    190  1.14       erh }
    191  1.14       erh 
    192  1.14       erh void
    193  1.14       erh native_to_linux_old_sigaction(bsa, lsa)
    194  1.14       erh 	struct sigaction *bsa;
    195  1.14       erh 	struct linux_old_sigaction *lsa;
    196  1.14       erh {
    197  1.14       erh 
    198  1.14       erh 	/* Clear sa_flags and sa_restorer (if it exists) */
    199  1.14       erh 	bzero(lsa, sizeof(struct linux_old_sigaction));
    200  1.14       erh 
    201  1.14       erh 	/* ...and fill in the mask and flags */
    202  1.14       erh 	native_to_linux_old_sigset(&bsa->sa_mask, &lsa->sa_mask);
    203  1.14       erh 	if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
    204  1.14       erh 		lsa->sa_flags |= LINUX_SA_NOCLDSTOP;
    205  1.14       erh 	if ((bsa->sa_flags & SA_ONSTACK) != 0)
    206  1.14       erh 		lsa->sa_flags |= LINUX_SA_ONSTACK;
    207  1.14       erh 	if ((bsa->sa_flags & SA_RESTART) != 0)
    208  1.14       erh 		lsa->sa_flags |= LINUX_SA_RESTART;
    209  1.14       erh 	if ((bsa->sa_flags & SA_NODEFER) != 0)
    210  1.14       erh 		lsa->sa_flags |= LINUX_SA_NOMASK;
    211  1.14       erh 	if ((bsa->sa_flags & SA_RESETHAND) != 0)
    212  1.14       erh 		lsa->sa_flags |= LINUX_SA_ONESHOT;
    213  1.14       erh 	if ((bsa->sa_flags & SA_SIGINFO) != 0)
    214  1.14       erh 		lsa->sa_flags |= LINUX_SA_SIGINFO;
    215  1.14       erh 	lsa->sa_handler = bsa->sa_handler;
    216  1.14       erh }
    217  1.14       erh 
    218  1.14       erh /* ...and the new sigaction conversion funcs. */
    219  1.14       erh void
    220  1.12   mycroft linux_to_native_sigaction(lsa, bsa)
    221   1.1      fvdl 	struct linux_sigaction *lsa;
    222   1.1      fvdl 	struct sigaction *bsa;
    223   1.1      fvdl {
    224   1.6   mycroft 
    225   1.1      fvdl 	bsa->sa_handler = lsa->sa_handler;
    226  1.12   mycroft 	linux_to_native_sigset(&lsa->sa_mask, &bsa->sa_mask);
    227   1.1      fvdl 	bsa->sa_flags = 0;
    228  1.12   mycroft 	if ((lsa->sa_flags & LINUX_SA_NOCLDSTOP) != 0)
    229  1.12   mycroft 		bsa->sa_flags |= SA_NOCLDSTOP;
    230   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_ONSTACK) != 0)
    231   1.6   mycroft 		bsa->sa_flags |= SA_ONSTACK;
    232   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_RESTART) != 0)
    233   1.6   mycroft 		bsa->sa_flags |= SA_RESTART;
    234   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_ONESHOT) != 0)
    235   1.6   mycroft 		bsa->sa_flags |= SA_RESETHAND;
    236   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_NOMASK) != 0)
    237   1.6   mycroft 		bsa->sa_flags |= SA_NODEFER;
    238  1.14       erh 	if ((lsa->sa_flags & LINUX_SA_SIGINFO) != 0)
    239  1.14       erh 		bsa->sa_flags |= SA_SIGINFO;
    240  1.13        tv #ifdef DEBUG
    241  1.12   mycroft 	if ((lsa->sa_flags & ~LINUX_SA_ALLBITS) != 0)
    242  1.12   mycroft /*XXX*/		printf("linux_to_native_sigaction: extra bits ignored\n");
    243  1.12   mycroft 	if (lsa->sa_restorer != 0)
    244  1.12   mycroft /*XXX*/		printf("linux_to_native_sigaction: sa_restorer ignored\n");
    245  1.13        tv #endif
    246   1.1      fvdl }
    247   1.1      fvdl 
    248   1.1      fvdl void
    249  1.12   mycroft native_to_linux_sigaction(bsa, lsa)
    250   1.1      fvdl 	struct sigaction *bsa;
    251   1.1      fvdl 	struct linux_sigaction *lsa;
    252   1.1      fvdl {
    253   1.6   mycroft 
    254  1.14       erh 	/* Clear sa_flags and sa_restorer (if it exists) */
    255  1.14       erh 	bzero(lsa, sizeof(struct linux_sigaction));
    256  1.14       erh 
    257  1.14       erh 	/* ...and fill in the mask and flags */
    258  1.12   mycroft 	native_to_linux_sigset(&bsa->sa_mask, &lsa->sa_mask);
    259   1.6   mycroft 	if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
    260   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_NOCLDSTOP;
    261   1.6   mycroft 	if ((bsa->sa_flags & SA_ONSTACK) != 0)
    262   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_ONSTACK;
    263   1.6   mycroft 	if ((bsa->sa_flags & SA_RESTART) != 0)
    264   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_RESTART;
    265   1.6   mycroft 	if ((bsa->sa_flags & SA_NODEFER) != 0)
    266   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_NOMASK;
    267   1.6   mycroft 	if ((bsa->sa_flags & SA_RESETHAND) != 0)
    268   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_ONESHOT;
    269  1.14       erh 	if ((bsa->sa_flags & SA_SIGINFO) != 0)
    270  1.14       erh 		lsa->sa_flags |= LINUX_SA_SIGINFO;
    271  1.14       erh 	lsa->sa_handler = bsa->sa_handler;
    272   1.1      fvdl }
    273   1.1      fvdl 
    274  1.14       erh /* ----------------------------------------------------------------------- */
    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.14       erh linux_sys_rt_sigaction(p, v, retval)
    283   1.1      fvdl 	register struct proc *p;
    284   1.8   thorpej 	void *v;
    285   1.8   thorpej 	register_t *retval;
    286   1.8   thorpej {
    287  1.14       erh 	struct linux_sys_rt_sigaction_args /* {
    288   1.1      fvdl 		syscallarg(int) signum;
    289  1.12   mycroft 		syscallarg(const struct linux_sigaction *) nsa;
    290   1.1      fvdl 		syscallarg(struct linux_sigaction *) osa;
    291  1.14       erh 		syscallarg(size_t) sigsetsize;
    292   1.8   thorpej 	} */ *uap = v;
    293  1.12   mycroft 	struct linux_sigaction nlsa, olsa;
    294  1.12   mycroft 	struct sigaction nbsa, obsa;
    295   1.1      fvdl 	int error;
    296   1.1      fvdl 
    297  1.14       erh 	/* XXX XAX linux_sigset_t or struct linux_sigaction here? */
    298  1.14       erh 	if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
    299  1.14       erh 		return (EINVAL);
    300  1.14       erh 
    301  1.12   mycroft 	if (SCARG(uap, nsa)) {
    302  1.12   mycroft 		error = copyin(SCARG(uap, nsa), &nlsa, sizeof(nlsa));
    303  1.12   mycroft 		if (error)
    304  1.12   mycroft 			return (error);
    305  1.12   mycroft 		linux_to_native_sigaction(&nlsa, &nbsa);
    306  1.12   mycroft 	}
    307  1.12   mycroft 	error = sigaction1(p, linux_to_native_sig[SCARG(uap, signum)],
    308  1.12   mycroft 	    SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0);
    309  1.12   mycroft 	if (error)
    310  1.12   mycroft 		return (error);
    311  1.12   mycroft 	if (SCARG(uap, osa)) {
    312  1.12   mycroft 		native_to_linux_sigaction(&obsa, &olsa);
    313  1.12   mycroft 		error = copyout(&olsa, SCARG(uap, osa), sizeof(olsa));
    314  1.12   mycroft 		if (error)
    315  1.12   mycroft 			return (error);
    316   1.1      fvdl 	}
    317  1.12   mycroft 	return (0);
    318   1.1      fvdl }
    319   1.1      fvdl 
    320   1.1      fvdl int
    321  1.14       erh linux_sys_rt_sigprocmask(p, v, retval)
    322   1.1      fvdl 	register struct proc *p;
    323   1.8   thorpej 	void *v;
    324   1.8   thorpej 	register_t *retval;
    325   1.8   thorpej {
    326  1.14       erh 	/* Use non-rt function: sigsetsize is ignored. */
    327  1.14       erh 	/* Assume sizeof(linux_sigset_t) == sizeof(linux_old_sigset_t) */
    328  1.14       erh 	return(linux_sys_sigprocmask(p, v, retval));
    329  1.14       erh }
    330   1.1      fvdl 
    331   1.1      fvdl 
    332   1.1      fvdl int
    333   1.9   mycroft linux_sys_sigprocmask(p, v, retval)
    334   1.1      fvdl 	register struct proc *p;
    335   1.8   thorpej 	void *v;
    336   1.8   thorpej 	register_t *retval;
    337   1.8   thorpej {
    338   1.9   mycroft 	struct linux_sys_sigprocmask_args /* {
    339   1.1      fvdl 		syscallarg(int) how;
    340  1.14       erh 		syscallarg(const linux_old_sigset_t *) set;
    341  1.14       erh 		syscallarg(linux_old_sigset_t *) oset;
    342   1.8   thorpej 	} */ *uap = v;
    343  1.14       erh 	linux_old_sigset_t nlss, olss;
    344  1.12   mycroft 	sigset_t nbss, obss;
    345  1.12   mycroft 	int how;
    346  1.12   mycroft 	int error;
    347   1.1      fvdl 
    348   1.1      fvdl 	switch (SCARG(uap, how)) {
    349   1.1      fvdl 	case LINUX_SIG_BLOCK:
    350  1.12   mycroft 		how = SIG_BLOCK;
    351   1.1      fvdl 		break;
    352   1.1      fvdl 	case LINUX_SIG_UNBLOCK:
    353  1.12   mycroft 		how = SIG_UNBLOCK;
    354   1.1      fvdl 		break;
    355   1.1      fvdl 	case LINUX_SIG_SETMASK:
    356  1.12   mycroft 		how = SIG_SETMASK;
    357   1.1      fvdl 		break;
    358   1.1      fvdl 	default:
    359  1.12   mycroft 		return (EINVAL);
    360   1.1      fvdl 	}
    361   1.1      fvdl 
    362  1.12   mycroft 	if (SCARG(uap, set)) {
    363  1.12   mycroft 		error = copyin(SCARG(uap, set), &nlss, sizeof(nlss));
    364  1.12   mycroft 		if (error)
    365  1.12   mycroft 			return (error);
    366  1.14       erh 		linux_old_to_native_sigset(&nlss, &nbss);
    367  1.12   mycroft 	}
    368  1.12   mycroft 	error = sigprocmask1(p, how,
    369  1.12   mycroft 	    SCARG(uap, set) ? &nbss : 0, SCARG(uap, oset) ? &obss : 0);
    370  1.12   mycroft 	if (error)
    371  1.12   mycroft 		return (error);
    372  1.12   mycroft 	if (SCARG(uap, oset)) {
    373  1.14       erh 		native_to_linux_old_sigset(&obss, &olss);
    374  1.12   mycroft 		error = copyout(&olss, SCARG(uap, oset), sizeof(olss));
    375  1.12   mycroft 		if (error)
    376  1.12   mycroft 			return (error);
    377  1.12   mycroft 	}
    378  1.12   mycroft 	return (error);
    379   1.1      fvdl }
    380   1.1      fvdl 
    381   1.1      fvdl int
    382  1.14       erh linux_sys_rt_sigpending(p, v, retval)
    383   1.6   mycroft 	register struct proc *p;
    384   1.9   mycroft 	void *v;
    385   1.1      fvdl 	register_t *retval;
    386   1.1      fvdl {
    387  1.14       erh 	struct linux_sys_rt_sigpending_args /* {
    388  1.14       erh 		syscallarg(linux_sigset_t *) set;
    389  1.14       erh 		syscallarg(size_t) sigsetsize;
    390  1.14       erh 	} */ *uap = v;
    391  1.12   mycroft 	sigset_t bss;
    392  1.12   mycroft 	linux_sigset_t lss;
    393   1.6   mycroft 
    394  1.14       erh 	if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
    395  1.14       erh 		return (EINVAL);
    396  1.14       erh 
    397  1.14       erh 	sigpending1(p, &bss);
    398  1.12   mycroft 	native_to_linux_sigset(&bss, &lss);
    399  1.14       erh 	return copyout(&lss, SCARG(uap, set), sizeof(lss));
    400   1.1      fvdl }
    401   1.1      fvdl int
    402   1.9   mycroft linux_sys_sigpending(p, v, retval)
    403   1.6   mycroft 	register struct proc *p;
    404   1.8   thorpej 	void *v;
    405   1.8   thorpej 	register_t *retval;
    406   1.8   thorpej {
    407   1.9   mycroft 	struct linux_sys_sigpending_args /* {
    408  1.14       erh 		syscallarg(linux_old_sigset_t *) mask;
    409   1.8   thorpej 	} */ *uap = v;
    410  1.12   mycroft 	sigset_t bss;
    411  1.14       erh 	linux_old_sigset_t lss;
    412   1.1      fvdl 
    413  1.12   mycroft 	sigpending1(p, &bss);
    414  1.14       erh 	native_to_linux_old_sigset(&bss, &lss);
    415  1.12   mycroft 	return copyout(&lss, SCARG(uap, set), sizeof(lss));
    416   1.1      fvdl }
    417   1.1      fvdl 
    418   1.1      fvdl int
    419   1.9   mycroft linux_sys_sigsuspend(p, v, retval)
    420   1.6   mycroft 	register struct proc *p;
    421   1.8   thorpej 	void *v;
    422   1.8   thorpej 	register_t *retval;
    423   1.8   thorpej {
    424   1.9   mycroft 	struct linux_sys_sigsuspend_args /* {
    425   1.3      fvdl 		syscallarg(caddr_t) restart;
    426   1.3      fvdl 		syscallarg(int) oldmask;
    427   1.1      fvdl 		syscallarg(int) mask;
    428   1.8   thorpej 	} */ *uap = v;
    429  1.14       erh 	linux_old_sigset_t lss;
    430  1.14       erh 	sigset_t bss;
    431  1.14       erh 
    432  1.14       erh 	lss = SCARG(uap, mask);
    433  1.14       erh 	linux_old_to_native_sigset(&lss, &bss);
    434  1.14       erh 	return (sigsuspend1(p, &bss));
    435  1.14       erh }
    436  1.14       erh int
    437  1.14       erh linux_sys_rt_sigsuspend(p, v, retval)
    438  1.14       erh 	register struct proc *p;
    439  1.14       erh 	void *v;
    440  1.14       erh 	register_t *retval;
    441  1.14       erh {
    442  1.14       erh 	struct linux_sys_rt_sigsuspend_args /* {
    443  1.14       erh 		syscallarg(linux_sigset_t *) unewset;
    444  1.14       erh 		syscallarg(size_t) sigsetsize;
    445  1.14       erh 	} */ *uap = v;
    446  1.12   mycroft 	linux_sigset_t lss;
    447  1.12   mycroft 	sigset_t bss;
    448  1.14       erh 	int error;
    449  1.14       erh 
    450  1.14       erh 	if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
    451  1.14       erh 		return (EINVAL);
    452  1.14       erh 
    453  1.14       erh 	error = copyin(SCARG(uap, unewset), &lss, sizeof(linux_sigset_t));
    454  1.14       erh 	if (error)
    455  1.14       erh 		return (error);
    456  1.14       erh 
    457  1.12   mycroft 	linux_to_native_sigset(&lss, &bss);
    458  1.14       erh 
    459  1.12   mycroft 	return (sigsuspend1(p, &bss));
    460   1.3      fvdl }
    461   1.3      fvdl 
    462   1.3      fvdl /*
    463  1.14       erh  * Once more: only a signal conversion is needed.
    464  1.14       erh  * Note: also used as sys_rt_queueinfo.  The info field is ignored.
    465   1.3      fvdl  */
    466   1.3      fvdl int
    467  1.14       erh linux_sys_rt_queueinfo(p, v, retval)
    468   1.6   mycroft 	register struct proc *p;
    469  1.14       erh 	void *v;
    470   1.3      fvdl 	register_t *retval;
    471  1.14       erh {
    472  1.14       erh 	/* XXX XAX This isn't this really int, int, siginfo_t *, is it? */
    473  1.14       erh #if 0
    474  1.14       erh 	struct linux_sys_rt_queueinfo_args /* {
    475  1.14       erh 		syscallarg(int) pid;
    476  1.14       erh 		syscallarg(int) signum;
    477  1.14       erh 		syscallarg(siginfo_t *) uinfo;
    478  1.14       erh 	} */ *uap = v;
    479  1.14       erh #endif
    480   1.3      fvdl 
    481  1.14       erh 	/* XXX To really implement this we need to	*/
    482  1.14       erh 	/* XXX keep a list of queued signals somewhere.	*/
    483  1.14       erh 	return (linux_sys_kill(p, v, retval));
    484   1.1      fvdl }
    485   1.1      fvdl 
    486   1.1      fvdl int
    487   1.9   mycroft linux_sys_kill(p, v, retval)
    488   1.6   mycroft 	register struct proc *p;
    489   1.8   thorpej 	void *v;
    490   1.8   thorpej 	register_t *retval;
    491   1.8   thorpej {
    492   1.9   mycroft 	struct linux_sys_kill_args /* {
    493   1.1      fvdl 		syscallarg(int) pid;
    494   1.1      fvdl 		syscallarg(int) signum;
    495   1.8   thorpej 	} */ *uap = v;
    496   1.9   mycroft 	struct sys_kill_args ka;
    497   1.6   mycroft 
    498   1.6   mycroft 	SCARG(&ka, pid) = SCARG(uap, pid);
    499  1.12   mycroft 	SCARG(&ka, signum) = linux_to_native_sig[SCARG(uap, signum)];
    500   1.9   mycroft 	return sys_kill(p, &ka, retval);
    501   1.1      fvdl }
    502