2003-01-18 10:40:44 +03:00
|
|
|
/* $NetBSD: ibcs2_signal.c,v 1.18 2003/01/18 07:40:45 thorpej Exp $ */
|
1995-08-14 04:44:12 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Scott Bartram
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-01-18 10:40:44 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ibcs2_signal.c,v 1.18 2003/01/18 07:40:45 thorpej Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mount.h>
|
1995-08-14 04:44:12 +04:00
|
|
|
#include <sys/kernel.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/signal.h>
|
1995-08-14 04:44:12 +04:00
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
2003-01-18 10:40:44 +03:00
|
|
|
#include <sys/sa.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
|
|
|
#include <compat/ibcs2/ibcs2_types.h>
|
1995-08-14 05:11:52 +04:00
|
|
|
#include <compat/ibcs2/ibcs2_signal.h>
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <compat/ibcs2/ibcs2_syscallargs.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_util.h>
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
#define ibcs2_sigmask(n) (1 << ((n) - 1))
|
1998-08-10 00:36:58 +04:00
|
|
|
#define ibcs2_sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
1995-08-14 04:44:12 +04:00
|
|
|
#define ibcs2_sigismember(s, n) (*(s) & ibcs2_sigmask(n))
|
|
|
|
#define ibcs2_sigaddset(s, n) (*(s) |= ibcs2_sigmask(n))
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2002-04-01 02:22:43 +04:00
|
|
|
extern const int native_to_ibcs2_signo[];
|
|
|
|
extern const int ibcs2_to_native_signo[];
|
1995-08-14 04:44:12 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
void ibcs2_to_native_sigaction __P((const struct ibcs2_sigaction *, struct sigaction *));
|
|
|
|
void native_to_ibcs2_sigaction __P((const struct sigaction *, struct ibcs2_sigaction *));
|
|
|
|
void ibcs2_to_native_sigaltstack __P((const struct ibcs2_sigaltstack *, struct sigaltstack *));
|
|
|
|
void native_to_ibcs2_sigaltstack __P((const struct sigaltstack *, struct ibcs2_sigaltstack *));
|
1996-05-03 21:05:16 +04:00
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
void
|
1998-09-11 16:50:05 +04:00
|
|
|
ibcs2_to_native_sigset(iss, bss)
|
1995-08-14 04:44:12 +04:00
|
|
|
const ibcs2_sigset_t *iss;
|
|
|
|
sigset_t *bss;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-08-14 04:44:12 +04:00
|
|
|
int i, newsig;
|
|
|
|
|
|
|
|
sigemptyset(bss);
|
|
|
|
for (i = 1; i < IBCS2_NSIG; i++) {
|
|
|
|
if (ibcs2_sigismember(iss, i)) {
|
2002-04-01 02:22:43 +04:00
|
|
|
newsig = ibcs2_to_native_signo[i];
|
1995-08-14 04:44:12 +04:00
|
|
|
if (newsig)
|
|
|
|
sigaddset(bss, newsig);
|
|
|
|
}
|
|
|
|
}
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
void
|
1998-09-11 16:50:05 +04:00
|
|
|
native_to_ibcs2_sigset(bss, iss)
|
1995-08-14 04:44:12 +04:00
|
|
|
const sigset_t *bss;
|
|
|
|
ibcs2_sigset_t *iss;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-08-14 04:44:12 +04:00
|
|
|
int i, newsig;
|
|
|
|
|
|
|
|
ibcs2_sigemptyset(iss);
|
|
|
|
for (i = 1; i < NSIG; i++) {
|
|
|
|
if (sigismember(bss, i)) {
|
2002-04-01 02:22:43 +04:00
|
|
|
newsig = native_to_ibcs2_signo[i];
|
1995-08-14 04:44:12 +04:00
|
|
|
if (newsig)
|
|
|
|
ibcs2_sigaddset(iss, newsig);
|
|
|
|
}
|
|
|
|
}
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
void
|
1998-09-11 16:50:05 +04:00
|
|
|
ibcs2_to_native_sigaction(isa, bsa)
|
|
|
|
const struct ibcs2_sigaction *isa;
|
1995-08-14 04:44:12 +04:00
|
|
|
struct sigaction *bsa;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
|
2002-11-26 21:43:20 +03:00
|
|
|
bsa->sa_handler = isa->ibcs2_sa_handler;
|
|
|
|
ibcs2_to_native_sigset(&isa->ibcs2_sa_mask, &bsa->sa_mask);
|
1995-08-14 04:44:12 +04:00
|
|
|
bsa->sa_flags = 0;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_NOCLDSTOP) != 0)
|
1995-08-14 04:44:12 +04:00
|
|
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_RESETHAND) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
bsa->sa_flags |= SA_RESETHAND;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_RESTART) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
bsa->sa_flags |= SA_RESTART;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_SIGINFO) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaction: SA_SIGINFO ignored\n");
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_NODEFER) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
bsa->sa_flags |= SA_NODEFER;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_ONSTACK) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
bsa->sa_flags |= SA_ONSTACK;
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & IBCS2_SA_NOCLDWAIT) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaction: SA_NOCLDWAIT ignored\n");
|
2002-11-26 21:43:20 +03:00
|
|
|
if ((isa->ibcs2_sa_flags & ~IBCS2_SA_ALLBITS) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaction: extra bits ignored\n");
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
void
|
1998-09-11 16:50:05 +04:00
|
|
|
native_to_ibcs2_sigaction(bsa, isa)
|
|
|
|
const struct sigaction *bsa;
|
1995-08-14 04:44:12 +04:00
|
|
|
struct ibcs2_sigaction *isa;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-08-14 04:44:12 +04:00
|
|
|
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_handler = bsa->sa_handler;
|
|
|
|
native_to_ibcs2_sigset(&bsa->sa_mask, &isa->ibcs2_sa_mask);
|
|
|
|
isa->ibcs2_sa_flags = 0;
|
1995-08-14 04:44:12 +04:00
|
|
|
if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_flags |= IBCS2_SA_NOCLDSTOP;
|
1998-09-11 16:50:05 +04:00
|
|
|
if ((bsa->sa_flags & SA_RESETHAND) != 0)
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_flags |= IBCS2_SA_RESETHAND;
|
1998-09-11 16:50:05 +04:00
|
|
|
if ((bsa->sa_flags & SA_RESTART) != 0)
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_flags |= IBCS2_SA_RESTART;
|
1998-09-11 16:50:05 +04:00
|
|
|
if ((bsa->sa_flags & SA_NODEFER) != 0)
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_flags |= IBCS2_SA_NODEFER;
|
1998-09-11 16:50:05 +04:00
|
|
|
if ((bsa->sa_flags & SA_ONSTACK) != 0)
|
2002-11-26 21:43:20 +03:00
|
|
|
isa->ibcs2_sa_flags |= IBCS2_SA_ONSTACK;
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ibcs2_to_native_sigaltstack(sss, bss)
|
|
|
|
const struct ibcs2_sigaltstack *sss;
|
|
|
|
struct sigaltstack *bss;
|
|
|
|
{
|
|
|
|
|
|
|
|
bss->ss_sp = sss->ss_sp;
|
|
|
|
bss->ss_size = sss->ss_size;
|
|
|
|
bss->ss_flags = 0;
|
|
|
|
if ((sss->ss_flags & IBCS2_SS_DISABLE) != 0)
|
|
|
|
bss->ss_flags |= SS_DISABLE;
|
|
|
|
if ((sss->ss_flags & IBCS2_SS_ONSTACK) != 0)
|
|
|
|
bss->ss_flags |= SS_ONSTACK;
|
|
|
|
if ((sss->ss_flags & ~IBCS2_SS_ALLBITS) != 0)
|
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaltstack: extra bits ignored\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
native_to_ibcs2_sigaltstack(bss, sss)
|
|
|
|
const struct sigaltstack *bss;
|
|
|
|
struct ibcs2_sigaltstack *sss;
|
|
|
|
{
|
|
|
|
|
|
|
|
sss->ss_sp = bss->ss_sp;
|
|
|
|
sss->ss_size = bss->ss_size;
|
|
|
|
sss->ss_flags = 0;
|
|
|
|
if ((bss->ss_flags & SS_DISABLE) != 0)
|
|
|
|
sss->ss_flags |= IBCS2_SS_DISABLE;
|
|
|
|
if ((bss->ss_flags & SS_ONSTACK) != 0)
|
|
|
|
sss->ss_flags |= IBCS2_SS_ONSTACK;
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigaction(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sigaction_args /* {
|
|
|
|
syscallarg(int) signum;
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(const struct ibcs2_sigaction *) nsa;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(struct ibcs2_sigaction *) osa;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1998-09-11 16:50:05 +04:00
|
|
|
struct ibcs2_sigaction nisa, oisa;
|
|
|
|
struct sigaction nbsa, obsa;
|
1995-08-14 04:44:12 +04:00
|
|
|
int error;
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, nsa)) {
|
|
|
|
error = copyin(SCARG(uap, nsa), &nisa, sizeof(nisa));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ibcs2_to_native_sigaction(&nisa, &nbsa);
|
|
|
|
}
|
2002-04-01 02:22:43 +04:00
|
|
|
error = sigaction1(p, ibcs2_to_native_signo[SCARG(uap, signum)],
|
2002-07-05 03:32:02 +04:00
|
|
|
SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0,
|
|
|
|
NULL, 0);
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (SCARG(uap, osa)) {
|
|
|
|
native_to_ibcs2_sigaction(&obsa, &oisa);
|
|
|
|
error = copyout(&oisa, SCARG(uap, osa), sizeof(oisa));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1995-08-14 04:44:12 +04:00
|
|
|
}
|
1998-09-11 16:50:05 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigaltstack(l, v, retval)
|
|
|
|
struct lwp *l;
|
1998-09-11 16:50:05 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_sigaltstack_args /* {
|
|
|
|
syscallarg(const struct ibcs2_sigaltstack *) nss;
|
|
|
|
syscallarg(struct ibcs2_sigaltstack *) oss;
|
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1998-09-11 16:50:05 +04:00
|
|
|
struct ibcs2_sigaltstack nsss, osss;
|
|
|
|
struct sigaltstack nbss, obss;
|
|
|
|
int error;
|
1995-08-14 04:44:12 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, nss)) {
|
|
|
|
error = copyin(SCARG(uap, nss), &nsss, sizeof(nsss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ibcs2_to_native_sigaltstack(&nsss, &nbss);
|
|
|
|
}
|
|
|
|
error = sigaltstack1(p,
|
|
|
|
SCARG(uap, nss) ? &nbss : 0, SCARG(uap, oss) ? &obss : 0);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (SCARG(uap, oss)) {
|
|
|
|
native_to_ibcs2_sigaltstack(&obss, &osss);
|
|
|
|
error = copyout(&osss, SCARG(uap, oss), sizeof(osss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigsys(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sigsys_args /* {
|
1995-08-14 04:44:12 +04:00
|
|
|
syscallarg(int) sig;
|
|
|
|
syscallarg(ibcs2_sig_t) fp;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
2002-04-01 02:22:43 +04:00
|
|
|
int signum = ibcs2_to_native_signo[IBCS2_SIGNO(SCARG(uap, sig))];
|
1998-09-11 16:50:05 +04:00
|
|
|
struct sigaction nbsa, obsa;
|
|
|
|
sigset_t ss;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (signum <= 0 || signum >= IBCS2_NSIG)
|
|
|
|
return (EINVAL);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
switch (IBCS2_SIGCALL(SCARG(uap, sig))) {
|
|
|
|
case IBCS2_SIGSET_MASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, fp) == IBCS2_SIG_HOLD)
|
|
|
|
goto sighold;
|
1995-08-14 04:44:12 +04:00
|
|
|
/* FALLTHROUGH */
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case IBCS2_SIGNAL_MASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
nbsa.sa_handler = (sig_t)SCARG(uap, fp);
|
|
|
|
sigemptyset(&nbsa.sa_mask);
|
|
|
|
nbsa.sa_flags = 0;
|
2002-07-05 03:32:02 +04:00
|
|
|
error = sigaction1(p, signum, &nbsa, &obsa, NULL, 0);
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
*retval = (int)obsa.sa_handler;
|
|
|
|
return (0);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case IBCS2_SIGHOLD_MASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
sighold:
|
|
|
|
sigemptyset(&ss);
|
|
|
|
sigaddset(&ss, signum);
|
|
|
|
return (sigprocmask1(p, SIG_BLOCK, &ss, 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case IBCS2_SIGRELSE_MASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
sigemptyset(&ss);
|
|
|
|
sigaddset(&ss, signum);
|
|
|
|
return (sigprocmask1(p, SIG_UNBLOCK, &ss, 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case IBCS2_SIGIGNORE_MASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
nbsa.sa_handler = SIG_IGN;
|
|
|
|
sigemptyset(&nbsa.sa_mask);
|
|
|
|
nbsa.sa_flags = 0;
|
2002-07-05 03:32:02 +04:00
|
|
|
return (sigaction1(p, signum, &nbsa, 0, NULL, 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
case IBCS2_SIGPAUSE_MASK:
|
2000-12-23 01:58:52 +03:00
|
|
|
ss = p->p_sigctx.ps_sigmask;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigdelset(&ss, signum);
|
|
|
|
return (sigsuspend1(p, &ss));
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
default:
|
1998-09-11 16:50:05 +04:00
|
|
|
return (ENOSYS);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigprocmask(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sigprocmask_args /* {
|
1995-08-14 04:44:12 +04:00
|
|
|
syscallarg(int) how;
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(const ibcs2_sigset_t *) set;
|
1995-08-14 04:44:12 +04:00
|
|
|
syscallarg(ibcs2_sigset_t *) oset;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1998-09-11 16:50:05 +04:00
|
|
|
ibcs2_sigset_t niss, oiss;
|
|
|
|
sigset_t nbss, obss;
|
|
|
|
int how;
|
|
|
|
int error;
|
1995-08-14 04:44:12 +04:00
|
|
|
|
|
|
|
switch (SCARG(uap, how)) {
|
|
|
|
case IBCS2_SIG_BLOCK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_BLOCK;
|
|
|
|
break;
|
1995-08-14 04:44:12 +04:00
|
|
|
case IBCS2_SIG_UNBLOCK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_UNBLOCK;
|
1995-08-14 04:44:12 +04:00
|
|
|
break;
|
|
|
|
case IBCS2_SIG_SETMASK:
|
1998-09-11 16:50:05 +04:00
|
|
|
how = SIG_SETMASK;
|
1995-08-14 04:44:12 +04:00
|
|
|
break;
|
|
|
|
default:
|
1998-09-11 16:50:05 +04:00
|
|
|
return (EINVAL);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
1995-08-14 04:44:12 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, set)) {
|
|
|
|
error = copyin(SCARG(uap, set), &niss, sizeof(niss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ibcs2_to_native_sigset(&niss, &nbss);
|
|
|
|
}
|
|
|
|
error = sigprocmask1(p, how,
|
|
|
|
SCARG(uap, set) ? &nbss : 0, SCARG(uap, oset) ? &obss : 0);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (SCARG(uap, oset)) {
|
|
|
|
native_to_ibcs2_sigset(&obss, &oiss);
|
|
|
|
error = copyout(&oiss, SCARG(uap, oset), sizeof(oiss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
return (0);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigpending(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-08-14 04:44:12 +04:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sigpending_args /* {
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(ibcs2_sigset_t *) set;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1995-08-14 04:44:12 +04:00
|
|
|
sigset_t bss;
|
|
|
|
ibcs2_sigset_t iss;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
sigpending1(p, &bss);
|
|
|
|
native_to_ibcs2_sigset(&bss, &iss);
|
|
|
|
return (copyout(&iss, SCARG(uap, set), sizeof(iss)));
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_sigsuspend(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-08-14 04:44:12 +04:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_sigsuspend_args /* {
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(const ibcs2_sigset_t *) set;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
2003-01-18 10:40:44 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1995-08-14 04:44:12 +04:00
|
|
|
ibcs2_sigset_t sss;
|
|
|
|
sigset_t bss;
|
|
|
|
int error;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, set)) {
|
|
|
|
error = copyin(SCARG(uap, set), &sss, sizeof(sss));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
ibcs2_to_native_sigset(&sss, &bss);
|
|
|
|
}
|
1995-08-14 04:44:12 +04:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
return (sigsuspend1(p, SCARG(uap, set) ? &bss : 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_pause(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-10-07 09:25:19 +03:00
|
|
|
void *v;
|
1995-08-14 04:44:12 +04:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
|
2003-01-18 10:40:44 +03:00
|
|
|
return (sigsuspend1(l->l_proc, 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-01-18 10:40:44 +03:00
|
|
|
ibcs2_sys_kill(l, v, retval)
|
|
|
|
struct lwp *l;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_kill_args /* {
|
1995-08-14 04:44:12 +04:00
|
|
|
syscallarg(int) pid;
|
|
|
|
syscallarg(int) signo;
|
1995-09-20 02:19:01 +04:00
|
|
|
} */ *uap = v;
|
1995-10-07 09:25:19 +03:00
|
|
|
struct sys_kill_args ka;
|
1995-03-14 18:12:17 +03:00
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
SCARG(&ka, pid) = SCARG(uap, pid);
|
2002-04-01 02:22:43 +04:00
|
|
|
SCARG(&ka, signum) = ibcs2_to_native_signo[SCARG(uap, signo)];
|
2003-01-18 10:40:44 +03:00
|
|
|
return sys_kill(l, &ka, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|