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