2001-01-18 23:28:15 +03:00
|
|
|
/* $NetBSD: ibcs2_signal.c,v 1.13 2001/01/18 20:28:25 jdolecek 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
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
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
int const native_to_ibcs2_sig[NSIG] = {
|
1995-08-14 04:44:12 +04:00
|
|
|
0, /* 0 */
|
1995-03-14 18:12:17 +03:00
|
|
|
IBCS2_SIGHUP, /* 1 */
|
|
|
|
IBCS2_SIGINT, /* 2 */
|
|
|
|
IBCS2_SIGQUIT, /* 3 */
|
|
|
|
IBCS2_SIGILL, /* 4 */
|
|
|
|
IBCS2_SIGTRAP, /* 5 */
|
|
|
|
IBCS2_SIGABRT, /* 6 */
|
|
|
|
IBCS2_SIGEMT, /* 7 */
|
|
|
|
IBCS2_SIGFPE, /* 8 */
|
|
|
|
IBCS2_SIGKILL, /* 9 */
|
|
|
|
IBCS2_SIGBUS, /* 10 */
|
|
|
|
IBCS2_SIGSEGV, /* 11 */
|
|
|
|
IBCS2_SIGSYS, /* 12 */
|
|
|
|
IBCS2_SIGPIPE, /* 13 */
|
|
|
|
IBCS2_SIGALRM, /* 14 */
|
|
|
|
IBCS2_SIGTERM, /* 15 */
|
1995-08-14 04:44:12 +04:00
|
|
|
0, /* 16 - SIGURG */
|
1995-03-14 18:12:17 +03:00
|
|
|
IBCS2_SIGSTOP, /* 17 */
|
|
|
|
IBCS2_SIGTSTP, /* 18 */
|
|
|
|
IBCS2_SIGCONT, /* 19 */
|
|
|
|
IBCS2_SIGCLD, /* 20 */
|
|
|
|
IBCS2_SIGTTIN, /* 21 */
|
|
|
|
IBCS2_SIGTTOU, /* 22 */
|
1995-08-14 04:44:12 +04:00
|
|
|
IBCS2_SIGPOLL, /* 23 */
|
1998-09-11 16:50:05 +04:00
|
|
|
IBCS2_SIGXCPU, /* 24 */
|
|
|
|
IBCS2_SIGXFSZ, /* 25 */
|
1995-03-14 18:12:17 +03:00
|
|
|
IBCS2_SIGVTALRM, /* 26 */
|
|
|
|
IBCS2_SIGPROF, /* 27 */
|
|
|
|
IBCS2_SIGWINCH, /* 28 */
|
1998-09-11 16:50:05 +04:00
|
|
|
0, /* 29 - SIGINFO */
|
1995-03-14 18:12:17 +03:00
|
|
|
IBCS2_SIGUSR1, /* 30 */
|
|
|
|
IBCS2_SIGUSR2, /* 31 */
|
1998-09-11 16:50:05 +04:00
|
|
|
IBCS2_SIGPWR, /* 32 */
|
1995-03-14 18:12:17 +03:00
|
|
|
};
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
int const ibcs2_to_native_sig[IBCS2_NSIG] = {
|
1995-08-14 04:44:12 +04:00
|
|
|
0, /* 0 */
|
|
|
|
SIGHUP, /* 1 */
|
|
|
|
SIGINT, /* 2 */
|
|
|
|
SIGQUIT, /* 3 */
|
|
|
|
SIGILL, /* 4 */
|
|
|
|
SIGTRAP, /* 5 */
|
|
|
|
SIGABRT, /* 6 */
|
|
|
|
SIGEMT, /* 7 */
|
|
|
|
SIGFPE, /* 8 */
|
|
|
|
SIGKILL, /* 9 */
|
|
|
|
SIGBUS, /* 10 */
|
|
|
|
SIGSEGV, /* 11 */
|
|
|
|
SIGSYS, /* 12 */
|
|
|
|
SIGPIPE, /* 13 */
|
|
|
|
SIGALRM, /* 14 */
|
|
|
|
SIGTERM, /* 15 */
|
|
|
|
SIGUSR1, /* 16 */
|
|
|
|
SIGUSR2, /* 17 */
|
|
|
|
SIGCHLD, /* 18 */
|
1998-09-11 16:50:05 +04:00
|
|
|
SIGPWR, /* 19 */
|
1995-08-14 04:44:12 +04:00
|
|
|
SIGWINCH, /* 20 */
|
1998-09-11 16:50:05 +04:00
|
|
|
0, /* 21 - SIGPHONE */
|
1995-08-14 04:44:12 +04:00
|
|
|
SIGIO, /* 22 */
|
|
|
|
SIGSTOP, /* 23 */
|
|
|
|
SIGTSTP, /* 24 */
|
|
|
|
SIGCONT, /* 25 */
|
|
|
|
SIGTTIN, /* 26 */
|
|
|
|
SIGTTOU, /* 27 */
|
|
|
|
SIGVTALRM, /* 28 */
|
|
|
|
SIGPROF, /* 29 */
|
1998-09-11 16:50:05 +04:00
|
|
|
SIGXCPU, /* 30 */
|
|
|
|
SIGXFSZ, /* 31 */
|
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)) {
|
1998-09-11 16:50:05 +04:00
|
|
|
newsig = ibcs2_to_native_sig[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)) {
|
1998-09-11 16:50:05 +04:00
|
|
|
newsig = native_to_ibcs2_sig[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
|
|
|
{
|
|
|
|
|
1995-08-14 04:44:12 +04:00
|
|
|
bsa->sa_handler = isa->sa_handler;
|
1998-09-11 16:50:05 +04:00
|
|
|
ibcs2_to_native_sigset(&isa->sa_mask, &bsa->sa_mask);
|
1995-08-14 04:44:12 +04:00
|
|
|
bsa->sa_flags = 0;
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_NOCLDSTOP) != 0)
|
|
|
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
1998-09-11 16:50:05 +04:00
|
|
|
if ((isa->sa_flags & IBCS2_SA_RESETHAND) != 0)
|
|
|
|
bsa->sa_flags |= SA_RESETHAND;
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_RESTART) != 0)
|
|
|
|
bsa->sa_flags |= SA_RESTART;
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_SIGINFO) != 0)
|
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaction: SA_SIGINFO ignored\n");
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_NODEFER) != 0)
|
|
|
|
bsa->sa_flags |= SA_NODEFER;
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_ONSTACK) != 0)
|
|
|
|
bsa->sa_flags |= SA_ONSTACK;
|
|
|
|
if ((isa->sa_flags & IBCS2_SA_NOCLDWAIT) != 0)
|
|
|
|
/*XXX*/ printf("ibcs2_to_native_sigaction: SA_NOCLDWAIT ignored\n");
|
|
|
|
if ((isa->sa_flags & ~IBCS2_SA_ALLBITS) != 0)
|
|
|
|
/*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
|
|
|
|
|
|
|
isa->sa_handler = bsa->sa_handler;
|
1998-09-11 16:50:05 +04:00
|
|
|
native_to_ibcs2_sigset(&bsa->sa_mask, &isa->sa_mask);
|
1995-08-14 04:44:12 +04:00
|
|
|
isa->sa_flags = 0;
|
|
|
|
if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
|
1998-09-11 16:50:05 +04:00
|
|
|
isa->sa_flags |= IBCS2_SA_NOCLDSTOP;
|
|
|
|
if ((bsa->sa_flags & SA_RESETHAND) != 0)
|
|
|
|
isa->sa_flags |= IBCS2_SA_RESETHAND;
|
|
|
|
if ((bsa->sa_flags & SA_RESTART) != 0)
|
|
|
|
isa->sa_flags |= IBCS2_SA_RESTART;
|
|
|
|
if ((bsa->sa_flags & SA_NODEFER) != 0)
|
|
|
|
isa->sa_flags |= IBCS2_SA_NODEFER;
|
|
|
|
if ((bsa->sa_flags & SA_ONSTACK) != 0)
|
|
|
|
isa->sa_flags |= IBCS2_SA_ONSTACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sigaction(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
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);
|
|
|
|
}
|
|
|
|
error = sigaction1(p, ibcs2_to_native_sig[SCARG(uap, signum)],
|
|
|
|
SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0);
|
|
|
|
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
|
|
|
|
ibcs2_sys_sigaltstack(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
|
|
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sigsys(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
1998-09-11 16:50:05 +04:00
|
|
|
int signum = ibcs2_to_native_sig[IBCS2_SIGNO(SCARG(uap, sig))];
|
|
|
|
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;
|
|
|
|
error = sigaction1(p, signum, &nbsa, &obsa);
|
|
|
|
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;
|
|
|
|
return (sigaction1(p, signum, &nbsa, 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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sigprocmask(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sigpending(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_sigsuspend(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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;
|
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
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_pause(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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
|
|
|
{
|
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
return (sigsuspend1(p, 0));
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_kill(p, v, retval)
|
2000-03-30 15:24:16 +04:00
|
|
|
struct proc *p;
|
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);
|
1998-09-11 16:50:05 +04:00
|
|
|
SCARG(&ka, signum) = ibcs2_to_native_sig[SCARG(uap, signo)];
|
1995-10-07 09:25:19 +03:00
|
|
|
return sys_kill(p, &ka, retval);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|