Home | History | Annotate | Line # | Download | only in common
linux_signal.c revision 1.13
      1  1.13        tv /*	$NetBSD: linux_signal.c,v 1.13 1998/09/29 14:15:49 tv 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.7   mycroft #include <compat/linux/linux_signal.h>
     52   1.1      fvdl #include <compat/linux/linux_syscallargs.h>
     53   1.1      fvdl #include <compat/linux/linux_util.h>
     54   1.1      fvdl 
     55   1.6   mycroft #define	linux_sigmask(n)	(1 << ((n) - 1))
     56  1.11     perry #define	linux_sigemptyset(s)	memset((s), 0, sizeof(*(s)))
     57   1.6   mycroft #define	linux_sigismember(s, n)	(*(s) & linux_sigmask(n))
     58   1.6   mycroft #define	linux_sigaddset(s, n)	(*(s) |= linux_sigmask(n))
     59   1.6   mycroft 
     60  1.12   mycroft int native_to_linux_sig[NSIG] = {
     61   1.6   mycroft 	0,
     62   1.6   mycroft 	LINUX_SIGHUP,
     63   1.6   mycroft 	LINUX_SIGINT,
     64   1.6   mycroft 	LINUX_SIGQUIT,
     65   1.6   mycroft 	LINUX_SIGILL,
     66   1.6   mycroft 	LINUX_SIGTRAP,
     67   1.6   mycroft 	LINUX_SIGABRT,
     68  1.12   mycroft 	0,			/* SIGEMT */
     69   1.6   mycroft 	LINUX_SIGFPE,
     70   1.6   mycroft 	LINUX_SIGKILL,
     71   1.6   mycroft 	LINUX_SIGBUS,
     72   1.6   mycroft 	LINUX_SIGSEGV,
     73  1.12   mycroft 	0,			/* SIGSEGV */
     74   1.6   mycroft 	LINUX_SIGPIPE,
     75   1.6   mycroft 	LINUX_SIGALRM,
     76   1.6   mycroft 	LINUX_SIGTERM,
     77   1.6   mycroft 	LINUX_SIGURG,
     78   1.6   mycroft 	LINUX_SIGSTOP,
     79   1.6   mycroft 	LINUX_SIGTSTP,
     80   1.6   mycroft 	LINUX_SIGCONT,
     81   1.6   mycroft 	LINUX_SIGCHLD,
     82   1.6   mycroft 	LINUX_SIGTTIN,
     83   1.6   mycroft 	LINUX_SIGTTOU,
     84   1.6   mycroft 	LINUX_SIGIO,
     85   1.6   mycroft 	LINUX_SIGXCPU,
     86   1.6   mycroft 	LINUX_SIGXFSZ,
     87   1.6   mycroft 	LINUX_SIGVTALRM,
     88   1.6   mycroft 	LINUX_SIGPROF,
     89   1.6   mycroft 	LINUX_SIGWINCH,
     90  1.12   mycroft 	0,			/* SIGINFO */
     91   1.6   mycroft 	LINUX_SIGUSR1,
     92   1.6   mycroft 	LINUX_SIGUSR2,
     93  1.12   mycroft 	LINUX_SIGPWR,
     94   1.6   mycroft };
     95   1.6   mycroft 
     96  1.12   mycroft int linux_to_native_sig[LINUX_NSIG] = {
     97   1.6   mycroft 	0,
     98   1.6   mycroft 	SIGHUP,
     99   1.6   mycroft 	SIGINT,
    100   1.6   mycroft 	SIGQUIT,
    101   1.6   mycroft 	SIGILL,
    102   1.6   mycroft 	SIGTRAP,
    103   1.6   mycroft 	SIGABRT,
    104   1.6   mycroft 	SIGBUS,
    105   1.6   mycroft 	SIGFPE,
    106   1.6   mycroft 	SIGKILL,
    107   1.6   mycroft 	SIGUSR1,
    108   1.6   mycroft 	SIGSEGV,
    109   1.6   mycroft 	SIGUSR2,
    110   1.6   mycroft 	SIGPIPE,
    111   1.6   mycroft 	SIGALRM,
    112   1.6   mycroft 	SIGTERM,
    113  1.12   mycroft 	0,			/* SIGSTKFLT */
    114   1.6   mycroft 	SIGCHLD,
    115   1.6   mycroft 	SIGCONT,
    116   1.6   mycroft 	SIGSTOP,
    117   1.6   mycroft 	SIGTSTP,
    118   1.6   mycroft 	SIGTTIN,
    119   1.6   mycroft 	SIGTTOU,
    120   1.6   mycroft 	SIGURG,
    121   1.6   mycroft 	SIGXCPU,
    122   1.6   mycroft 	SIGXFSZ,
    123   1.6   mycroft 	SIGVTALRM,
    124   1.6   mycroft 	SIGPROF,
    125   1.6   mycroft 	SIGWINCH,
    126   1.6   mycroft 	SIGIO,
    127  1.12   mycroft 	SIGPWR,
    128  1.12   mycroft 	0,			/* SIGUNUSED */
    129   1.6   mycroft };
    130   1.1      fvdl 
    131  1.10  christos /* linux_signal.c */
    132  1.12   mycroft void linux_to_native_sigaction __P((struct linux_sigaction *, struct sigaction *));
    133  1.12   mycroft void native_to_linux_sigaction __P((struct sigaction *, struct linux_sigaction *));
    134  1.10  christos 
    135   1.6   mycroft void
    136  1.12   mycroft linux_to_native_sigset(lss, bss)
    137   1.1      fvdl 	const linux_sigset_t *lss;
    138   1.1      fvdl 	sigset_t *bss;
    139   1.1      fvdl {
    140   1.1      fvdl 	int i, newsig;
    141   1.1      fvdl 
    142   1.6   mycroft 	sigemptyset(bss);
    143   1.6   mycroft 	for (i = 1; i < LINUX_NSIG; i++) {
    144   1.6   mycroft 		if (linux_sigismember(lss, i)) {
    145  1.12   mycroft 			newsig = linux_to_native_sig[i];
    146   1.1      fvdl 			if (newsig)
    147   1.6   mycroft 				sigaddset(bss, newsig);
    148   1.1      fvdl 		}
    149   1.1      fvdl 	}
    150   1.1      fvdl }
    151   1.1      fvdl 
    152   1.1      fvdl void
    153  1.12   mycroft native_to_linux_sigset(bss, lss)
    154   1.1      fvdl 	const sigset_t *bss;
    155   1.1      fvdl 	linux_sigset_t *lss;
    156   1.1      fvdl {
    157   1.1      fvdl 	int i, newsig;
    158   1.1      fvdl 
    159   1.6   mycroft 	linux_sigemptyset(lss);
    160   1.6   mycroft 	for (i = 1; i < NSIG; i++) {
    161   1.6   mycroft 		if (sigismember(bss, i)) {
    162  1.12   mycroft 			newsig = native_to_linux_sig[i];
    163   1.1      fvdl 			if (newsig)
    164   1.6   mycroft 				linux_sigaddset(lss, newsig);
    165   1.1      fvdl 		}
    166   1.1      fvdl 	}
    167   1.1      fvdl }
    168   1.1      fvdl 
    169   1.1      fvdl /*
    170   1.1      fvdl  * Convert between Linux and BSD sigaction structures. Linux has
    171   1.6   mycroft  * one extra field (sa_restorer) which we don't support.
    172   1.1      fvdl  */
    173   1.1      fvdl void
    174  1.12   mycroft linux_to_native_sigaction(lsa, bsa)
    175   1.1      fvdl 	struct linux_sigaction *lsa;
    176   1.1      fvdl 	struct sigaction *bsa;
    177   1.1      fvdl {
    178   1.6   mycroft 
    179   1.1      fvdl 	bsa->sa_handler = lsa->sa_handler;
    180  1.12   mycroft 	linux_to_native_sigset(&lsa->sa_mask, &bsa->sa_mask);
    181   1.1      fvdl 	bsa->sa_flags = 0;
    182  1.12   mycroft 	if ((lsa->sa_flags & LINUX_SA_NOCLDSTOP) != 0)
    183  1.12   mycroft 		bsa->sa_flags |= SA_NOCLDSTOP;
    184   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_ONSTACK) != 0)
    185   1.6   mycroft 		bsa->sa_flags |= SA_ONSTACK;
    186   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_RESTART) != 0)
    187   1.6   mycroft 		bsa->sa_flags |= SA_RESTART;
    188   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_ONESHOT) != 0)
    189   1.6   mycroft 		bsa->sa_flags |= SA_RESETHAND;
    190   1.6   mycroft 	if ((lsa->sa_flags & LINUX_SA_NOMASK) != 0)
    191   1.6   mycroft 		bsa->sa_flags |= SA_NODEFER;
    192  1.13        tv #ifdef DEBUG
    193  1.12   mycroft 	if ((lsa->sa_flags & ~LINUX_SA_ALLBITS) != 0)
    194  1.12   mycroft /*XXX*/		printf("linux_to_native_sigaction: extra bits ignored\n");
    195  1.12   mycroft 	if (lsa->sa_restorer != 0)
    196  1.12   mycroft /*XXX*/		printf("linux_to_native_sigaction: sa_restorer ignored\n");
    197  1.13        tv #endif
    198   1.1      fvdl }
    199   1.1      fvdl 
    200   1.1      fvdl void
    201  1.12   mycroft native_to_linux_sigaction(bsa, lsa)
    202   1.1      fvdl 	struct sigaction *bsa;
    203   1.1      fvdl 	struct linux_sigaction *lsa;
    204   1.1      fvdl {
    205   1.6   mycroft 
    206   1.1      fvdl 	lsa->sa_handler = bsa->sa_handler;
    207  1.12   mycroft 	native_to_linux_sigset(&bsa->sa_mask, &lsa->sa_mask);
    208   1.1      fvdl 	lsa->sa_flags = 0;
    209   1.6   mycroft 	if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
    210   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_NOCLDSTOP;
    211   1.6   mycroft 	if ((bsa->sa_flags & SA_ONSTACK) != 0)
    212   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_ONSTACK;
    213   1.6   mycroft 	if ((bsa->sa_flags & SA_RESTART) != 0)
    214   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_RESTART;
    215   1.6   mycroft 	if ((bsa->sa_flags & SA_NODEFER) != 0)
    216   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_NOMASK;
    217   1.6   mycroft 	if ((bsa->sa_flags & SA_RESETHAND) != 0)
    218   1.6   mycroft 		lsa->sa_flags |= LINUX_SA_ONESHOT;
    219   1.1      fvdl 	lsa->sa_restorer = NULL;
    220   1.1      fvdl }
    221   1.1      fvdl 
    222   1.1      fvdl 
    223   1.1      fvdl /*
    224   1.1      fvdl  * The Linux sigaction() system call. Do the usual conversions,
    225   1.1      fvdl  * and just call sigaction(). Some flags and values are silently
    226   1.1      fvdl  * ignored (see above).
    227   1.1      fvdl  */
    228   1.1      fvdl int
    229   1.9   mycroft linux_sys_sigaction(p, v, retval)
    230   1.1      fvdl 	register struct proc *p;
    231   1.8   thorpej 	void *v;
    232   1.8   thorpej 	register_t *retval;
    233   1.8   thorpej {
    234   1.9   mycroft 	struct linux_sys_sigaction_args /* {
    235   1.1      fvdl 		syscallarg(int) signum;
    236  1.12   mycroft 		syscallarg(const struct linux_sigaction *) nsa;
    237   1.1      fvdl 		syscallarg(struct linux_sigaction *) osa;
    238   1.8   thorpej 	} */ *uap = v;
    239  1.12   mycroft 	struct linux_sigaction nlsa, olsa;
    240  1.12   mycroft 	struct sigaction nbsa, obsa;
    241   1.1      fvdl 	int error;
    242   1.1      fvdl 
    243  1.12   mycroft 	if (SCARG(uap, nsa)) {
    244  1.12   mycroft 		error = copyin(SCARG(uap, nsa), &nlsa, sizeof(nlsa));
    245  1.12   mycroft 		if (error)
    246  1.12   mycroft 			return (error);
    247  1.12   mycroft 		linux_to_native_sigaction(&nlsa, &nbsa);
    248  1.12   mycroft 	}
    249  1.12   mycroft 	error = sigaction1(p, linux_to_native_sig[SCARG(uap, signum)],
    250  1.12   mycroft 	    SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0);
    251  1.12   mycroft 	if (error)
    252  1.12   mycroft 		return (error);
    253  1.12   mycroft 	if (SCARG(uap, osa)) {
    254  1.12   mycroft 		native_to_linux_sigaction(&obsa, &olsa);
    255  1.12   mycroft 		error = copyout(&olsa, SCARG(uap, osa), sizeof(olsa));
    256  1.12   mycroft 		if (error)
    257  1.12   mycroft 			return (error);
    258   1.1      fvdl 	}
    259  1.12   mycroft 	return (0);
    260   1.1      fvdl }
    261   1.1      fvdl 
    262   1.1      fvdl /*
    263   1.1      fvdl  * The Linux signal() system call. I think that the signal() in the C
    264   1.1      fvdl  * library actually calls sigaction, so I doubt this one is ever used.
    265   1.1      fvdl  * But hey, it can't hurt having it here. The same restrictions as for
    266   1.1      fvdl  * sigaction() apply.
    267   1.1      fvdl  */
    268   1.1      fvdl int
    269   1.9   mycroft linux_sys_signal(p, v, retval)
    270   1.1      fvdl 	register struct proc *p;
    271   1.8   thorpej 	void *v;
    272   1.8   thorpej 	register_t *retval;
    273   1.8   thorpej {
    274   1.9   mycroft 	struct linux_sys_signal_args /* {
    275   1.1      fvdl 		syscallarg(int) sig;
    276   1.1      fvdl 		syscallarg(linux_handler_t) handler;
    277   1.8   thorpej 	} */ *uap = v;
    278  1.12   mycroft 	struct sigaction nbsa, obsa;
    279   1.1      fvdl 	int error;
    280   1.1      fvdl 
    281  1.12   mycroft 	nbsa.sa_handler = SCARG(uap, handler);
    282  1.12   mycroft 	sigemptyset(&nbsa.sa_mask);
    283  1.12   mycroft 	nbsa.sa_flags = SA_RESETHAND | SA_NODEFER;
    284  1.12   mycroft 	error = sigaction1(p, linux_to_native_sig[SCARG(uap, sig)],
    285  1.12   mycroft 	    &nbsa, &obsa);
    286  1.12   mycroft 	if (error)
    287  1.12   mycroft 		return (error);
    288  1.12   mycroft 	*retval = (int)obsa.sa_handler;
    289  1.12   mycroft 	return (0);
    290   1.1      fvdl }
    291   1.1      fvdl 
    292   1.1      fvdl int
    293   1.9   mycroft linux_sys_sigprocmask(p, v, retval)
    294   1.1      fvdl 	register struct proc *p;
    295   1.8   thorpej 	void *v;
    296   1.8   thorpej 	register_t *retval;
    297   1.8   thorpej {
    298   1.9   mycroft 	struct linux_sys_sigprocmask_args /* {
    299   1.1      fvdl 		syscallarg(int) how;
    300  1.12   mycroft 		syscallarg(const linux_sigset_t *) set;
    301   1.6   mycroft 		syscallarg(linux_sigset_t *) oset;
    302   1.8   thorpej 	} */ *uap = v;
    303  1.12   mycroft 	linux_sigset_t nlss, olss;
    304  1.12   mycroft 	sigset_t nbss, obss;
    305  1.12   mycroft 	int how;
    306  1.12   mycroft 	int error;
    307   1.1      fvdl 
    308   1.1      fvdl 	switch (SCARG(uap, how)) {
    309   1.1      fvdl 	case LINUX_SIG_BLOCK:
    310  1.12   mycroft 		how = SIG_BLOCK;
    311   1.1      fvdl 		break;
    312   1.1      fvdl 	case LINUX_SIG_UNBLOCK:
    313  1.12   mycroft 		how = SIG_UNBLOCK;
    314   1.1      fvdl 		break;
    315   1.1      fvdl 	case LINUX_SIG_SETMASK:
    316  1.12   mycroft 		how = SIG_SETMASK;
    317   1.1      fvdl 		break;
    318   1.1      fvdl 	default:
    319  1.12   mycroft 		return (EINVAL);
    320   1.1      fvdl 	}
    321   1.1      fvdl 
    322  1.12   mycroft 	if (SCARG(uap, set)) {
    323  1.12   mycroft 		error = copyin(SCARG(uap, set), &nlss, sizeof(nlss));
    324  1.12   mycroft 		if (error)
    325  1.12   mycroft 			return (error);
    326  1.12   mycroft 		linux_to_native_sigset(&nlss, &nbss);
    327  1.12   mycroft 	}
    328  1.12   mycroft 	error = sigprocmask1(p, how,
    329  1.12   mycroft 	    SCARG(uap, set) ? &nbss : 0, SCARG(uap, oset) ? &obss : 0);
    330  1.12   mycroft 	if (error)
    331  1.12   mycroft 		return (error);
    332  1.12   mycroft 	if (SCARG(uap, oset)) {
    333  1.12   mycroft 		native_to_linux_sigset(&obss, &olss);
    334  1.12   mycroft 		error = copyout(&olss, SCARG(uap, oset), sizeof(olss));
    335  1.12   mycroft 		if (error)
    336  1.12   mycroft 			return (error);
    337  1.12   mycroft 	}
    338  1.12   mycroft 	return (error);
    339   1.1      fvdl }
    340   1.1      fvdl 
    341   1.1      fvdl /* ARGSUSED */
    342   1.1      fvdl int
    343   1.9   mycroft linux_sys_siggetmask(p, v, retval)
    344   1.6   mycroft 	register struct proc *p;
    345   1.9   mycroft 	void *v;
    346   1.1      fvdl 	register_t *retval;
    347   1.1      fvdl {
    348  1.12   mycroft 	sigset_t bss;
    349  1.12   mycroft 	linux_sigset_t lss;
    350  1.12   mycroft 	int error;
    351   1.6   mycroft 
    352  1.12   mycroft 	error = sigprocmask1(p, SIG_SETMASK, 0, &bss);
    353  1.12   mycroft 	if (error)
    354  1.12   mycroft 		return (error);
    355  1.12   mycroft 	native_to_linux_sigset(&bss, &lss);
    356  1.12   mycroft 	*retval = lss;
    357  1.12   mycroft 	return (0);
    358   1.1      fvdl }
    359   1.1      fvdl 
    360   1.1      fvdl /*
    361   1.1      fvdl  * The following three functions fiddle with a process' signal mask.
    362   1.1      fvdl  * Convert the signal masks because of the different signal
    363   1.1      fvdl  * values for Linux. The need for this is the reason why
    364   1.1      fvdl  * they are here, and have not been mapped directly.
    365   1.1      fvdl  */
    366   1.1      fvdl int
    367   1.9   mycroft linux_sys_sigsetmask(p, v, retval)
    368   1.6   mycroft 	register struct proc *p;
    369   1.8   thorpej 	void *v;
    370   1.8   thorpej 	register_t *retval;
    371   1.8   thorpej {
    372   1.9   mycroft 	struct linux_sys_sigsetmask_args /* {
    373   1.1      fvdl 		syscallarg(linux_sigset_t) mask;
    374   1.8   thorpej 	} */ *uap = v;
    375  1.12   mycroft 	sigset_t nbss, obss;
    376  1.12   mycroft 	linux_sigset_t nlss, olss;
    377  1.12   mycroft 	int error;
    378   1.1      fvdl 
    379  1.12   mycroft 	nlss = SCARG(uap, mask);
    380  1.12   mycroft 	linux_to_native_sigset(&nlss, &nbss);
    381  1.12   mycroft 	error = sigprocmask1(p, SIG_SETMASK, &nbss, &obss);
    382  1.12   mycroft 	if (error)
    383  1.12   mycroft 		return (error);
    384  1.12   mycroft 	native_to_linux_sigset(&obss, &olss);
    385  1.12   mycroft 	*retval = olss;
    386  1.12   mycroft 	return (0);
    387   1.1      fvdl }
    388   1.1      fvdl 
    389   1.1      fvdl int
    390   1.9   mycroft linux_sys_sigpending(p, v, retval)
    391   1.6   mycroft 	register struct proc *p;
    392   1.8   thorpej 	void *v;
    393   1.8   thorpej 	register_t *retval;
    394   1.8   thorpej {
    395   1.9   mycroft 	struct linux_sys_sigpending_args /* {
    396  1.12   mycroft 		syscallarg(linux_sigset_t *) set;
    397   1.8   thorpej 	} */ *uap = v;
    398  1.12   mycroft 	sigset_t bss;
    399  1.12   mycroft 	linux_sigset_t lss;
    400   1.1      fvdl 
    401  1.12   mycroft 	sigpending1(p, &bss);
    402  1.12   mycroft 	native_to_linux_sigset(&bss, &lss);
    403  1.12   mycroft 	return copyout(&lss, SCARG(uap, set), sizeof(lss));
    404   1.1      fvdl }
    405   1.1      fvdl 
    406   1.1      fvdl int
    407   1.9   mycroft linux_sys_sigsuspend(p, v, retval)
    408   1.6   mycroft 	register struct proc *p;
    409   1.8   thorpej 	void *v;
    410   1.8   thorpej 	register_t *retval;
    411   1.8   thorpej {
    412   1.9   mycroft 	struct linux_sys_sigsuspend_args /* {
    413   1.3      fvdl 		syscallarg(caddr_t) restart;
    414   1.3      fvdl 		syscallarg(int) oldmask;
    415   1.1      fvdl 		syscallarg(int) mask;
    416   1.8   thorpej 	} */ *uap = v;
    417  1.12   mycroft 	linux_sigset_t lss;
    418  1.12   mycroft 	sigset_t bss;
    419  1.12   mycroft 
    420  1.12   mycroft 	lss = SCARG(uap, mask);
    421  1.12   mycroft 	linux_to_native_sigset(&lss, &bss);
    422  1.12   mycroft 	return (sigsuspend1(p, &bss));
    423   1.3      fvdl }
    424   1.3      fvdl 
    425   1.3      fvdl /*
    426   1.3      fvdl  * The deprecated pause(2), which is really just an instance
    427   1.3      fvdl  * of sigsuspend(2).
    428   1.3      fvdl  */
    429   1.3      fvdl int
    430   1.9   mycroft linux_sys_pause(p, v, retval)
    431   1.6   mycroft 	register struct proc *p;
    432   1.9   mycroft 	void *v;
    433   1.3      fvdl 	register_t *retval;
    434   1.3      fvdl {
    435   1.3      fvdl 
    436  1.12   mycroft 	return (sigsuspend1(p, 0));
    437   1.1      fvdl }
    438   1.1      fvdl 
    439   1.1      fvdl /*
    440   1.1      fvdl  * Once more: only a signal conversion is needed.
    441   1.1      fvdl  */
    442   1.1      fvdl int
    443   1.9   mycroft linux_sys_kill(p, v, retval)
    444   1.6   mycroft 	register struct proc *p;
    445   1.8   thorpej 	void *v;
    446   1.8   thorpej 	register_t *retval;
    447   1.8   thorpej {
    448   1.9   mycroft 	struct linux_sys_kill_args /* {
    449   1.1      fvdl 		syscallarg(int) pid;
    450   1.1      fvdl 		syscallarg(int) signum;
    451   1.8   thorpej 	} */ *uap = v;
    452   1.9   mycroft 	struct sys_kill_args ka;
    453   1.6   mycroft 
    454   1.6   mycroft 	SCARG(&ka, pid) = SCARG(uap, pid);
    455  1.12   mycroft 	SCARG(&ka, signum) = linux_to_native_sig[SCARG(uap, signum)];
    456   1.9   mycroft 	return sys_kill(p, &ka, retval);
    457   1.1      fvdl }
    458