Adapt to signal changes.

This commit is contained in:
thorpej 1998-10-01 06:35:09 +00:00
parent 502a65c40d
commit 6a7b0ca257
3 changed files with 134 additions and 122 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: hpux.h,v 1.13 1997/10/19 19:25:07 carrel Exp $ */ /* $NetBSD: hpux.h,v 1.14 1998/10/01 06:35:09 thorpej Exp $ */
/*- /*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -314,7 +314,7 @@ struct hpux_shmid_ds {
#define HPUX_FPE_INTDIV_TRAP 5 /* T_ZERODIV+USER */ #define HPUX_FPE_INTDIV_TRAP 5 /* T_ZERODIV+USER */
/* HP-UX POSIX signal stuff implementation */ /* HP-UX POSIX signal stuff implementation */
typedef struct __hpux_sigset_t { long sigset[8]; } hpux_sigset_t; typedef struct __hpux_sigset_t { int sigset[8]; } hpux_sigset_t;
struct hpux_sigaction { struct hpux_sigaction {
void (*sa_handler) __P((int)); void (*sa_handler) __P((int));
hpux_sigset_t sa_mask; hpux_sigset_t sa_mask;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_sig.c,v 1.17 1998/08/09 20:37:53 perry Exp $ */ /* $NetBSD: hpux_sig.c,v 1.18 1998/10/01 06:35:10 thorpej Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -90,48 +90,46 @@ hpux_sys_sigvec(p, v, retval)
register_t *retval; register_t *retval;
{ {
struct hpux_sys_sigvec_args *uap = v; struct hpux_sys_sigvec_args *uap = v;
struct sigvec vec; struct sigvec nsv, osv;
struct sigacts *ps = p->p_sigacts; struct sigaction nsa, osa;
struct sigvec *sv; int sig, error;
int sig;
int bit, error; /* XXX */
extern void compat_43_sigvec_to_sigaction
__P((const struct sigvec *, struct sigaction *));
extern void compat_43_sigaction_to_sigvec
__P((const struct sigaction *, struct sigvec *));
/*
* XXX We don't handle HPUXSV_RESET!
*/
sig = hpuxtobsdsig(SCARG(uap, signo)); sig = hpuxtobsdsig(SCARG(uap, signo));
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
return (EINVAL); return (EINVAL);
sv = &vec;
if (SCARG(uap, osv)) {
sv->sv_handler = ps->ps_sigact[sig];
sv->sv_mask = ps->ps_catchmask[sig];
bit = sigmask(sig);
sv->sv_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sv->sv_flags |= SV_ONSTACK;
if ((ps->ps_sigintr & bit) != 0)
sv->sv_flags |= SV_INTERRUPT;
if ((ps->ps_sigreset & bit) != 0)
sv->sv_flags |= HPUXSV_RESET;
sv->sv_mask &= ~bit;
error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv),
sizeof (vec));
if (error)
return (error);
}
if (SCARG(uap, nsv)) { if (SCARG(uap, nsv)) {
error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv, error = copyin(SCARG(uap, nsv), &nsv, sizeof(nsv));
sizeof (vec));
if (error) if (error)
return (error); return (error);
if (sig == SIGCONT && sv->sv_handler == SIG_IGN)
return (EINVAL); compat_43_sigvec_to_sigaction(&nsv, &nsa);
sv->sv_flags ^= SA_RESTART;
setsigvec(p, sig, (struct sigaction *)sv);
#if 0
/* XXX -- SOUSIG no longer exists, do something here */
if (sv->sv_flags & HPUXSV_RESET)
p->p_flag |= SOUSIG; /* XXX */
#endif
} }
error = sigaction1(p, sig,
SCARG(uap, nsv) ? &nsa : NULL,
SCARG(uap, osv) ? &osa : NULL);
if (error)
return (error);
if (SCARG(uap, osv)) {
compat_43_sigaction_to_sigvec(&osa, &osv);
error = copyout(&osv, SCARG(uap, osv), sizeof(osv));
if (error)
return (error);
}
return (0); return (0);
} }
@ -142,10 +140,16 @@ hpux_sys_sigblock(p, v, retval)
register_t *retval; register_t *retval;
{ {
struct hpux_sys_sigblock_args *uap = v; struct hpux_sys_sigblock_args *uap = v;
sigset_t nmask;
(void) splhigh(); (void) splhigh();
*retval = bsdtohpuxmask(p->p_sigmask);
p->p_sigmask |= hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask; bsdtohpuxmask(&p->p_sigmask, (int *)retval);
hpuxtobsdmask(SCARG(uap, mask), &nmask);
sigplusset(&nmask, &p->p_sigmask);
sigminusset(&sigcantmask, &p->p_sigmask);
(void) spl0(); (void) spl0();
return (0); return (0);
} }
@ -159,8 +163,12 @@ hpux_sys_sigsetmask(p, v, retval)
struct hpux_sys_sigsetmask_args *uap = v; struct hpux_sys_sigsetmask_args *uap = v;
(void) splhigh(); (void) splhigh();
*retval = bsdtohpuxmask(p->p_sigmask);
p->p_sigmask = hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask; bsdtohpuxmask(&p->p_sigmask, (int *)retval);
hpuxtobsdmask(SCARG(uap, mask), &p->p_sigmask);
sigminusset(&sigcantmask, &p->p_sigmask);
(void) spl0(); (void) spl0();
return (0); return (0);
} }
@ -172,9 +180,10 @@ hpux_sys_sigpause(p, v, retval)
register_t *retval; register_t *retval;
{ {
struct hpux_sys_sigpause_args *uap = v; struct hpux_sys_sigpause_args *uap = v;
sigset_t mask;
SCARG(uap, mask) = hpuxtobsdmask(SCARG(uap, mask)); hpuxtobsdmask(SCARG(uap, mask), &mask);
return (sys_sigsuspend(p, uap, retval)); return (sigsuspend1(p, &mask));
} }
/* not totally correct, but close enuf' */ /* not totally correct, but close enuf' */
@ -205,6 +214,8 @@ hpux_sys_kill(p, v, retval)
* Note that we receive new mask, not pointer, * Note that we receive new mask, not pointer,
* and return old mask as return value; * and return old mask as return value;
* the library stub does the rest. * the library stub does the rest.
*
* XXX We don't handle all HP-UX signals!
*/ */
int int
hpux_sys_sigprocmask(p, v, retval) hpux_sys_sigprocmask(p, v, retval)
@ -213,8 +224,9 @@ hpux_sys_sigprocmask(p, v, retval)
register_t *retval; register_t *retval;
{ {
struct hpux_sys_sigprocmask_args *uap = v; struct hpux_sys_sigprocmask_args *uap = v;
int mask, error = 0; int error = 0;
hpux_sigset_t sigset; hpux_sigset_t sigset;
sigset_t mask;
/* /*
* Copy out old mask first to ensure no errors. * Copy out old mask first to ensure no errors.
@ -222,26 +234,28 @@ hpux_sys_sigprocmask(p, v, retval)
*/ */
if (SCARG(uap, oset)) { if (SCARG(uap, oset)) {
memset((caddr_t)&sigset, 0, sizeof(sigset)); memset((caddr_t)&sigset, 0, sizeof(sigset));
sigset.sigset[0] = bsdtohpuxmask(p->p_sigmask); bsdtohpuxmask(&p->p_sigmask, &sigset.sigset[0]);
if (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, oset), error = copyout(&sigset, SCARG(uap, oset), sizeof(sigset));
sizeof(sigset))) if (error)
return (EFAULT); return (error);
} }
if (SCARG(uap, set)) { if (SCARG(uap, set)) {
if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset, error = copyin(SCARG(uap, set), &sigset, sizeof(sigset));
sizeof(sigset))) if (error)
return (EFAULT); return (error);
mask = hpuxtobsdmask(sigset.sigset[0]); hpuxtobsdmask(sigset.sigset[0], &mask);
(void) splhigh(); (void) splhigh();
switch (SCARG(uap, how)) { switch (SCARG(uap, how)) {
case HPUXSIG_BLOCK: case HPUXSIG_BLOCK:
p->p_sigmask |= mask &~ sigcantmask; sigplusset(&mask, &p->p_sigmask);
sigminusset(&sigcantmask, &p->p_sigmask);
break; break;
case HPUXSIG_UNBLOCK: case HPUXSIG_UNBLOCK:
p->p_sigmask &= ~mask; sigminusset(&mask, &p->p_sigmask);
break; break;
case HPUXSIG_SETMASK: case HPUXSIG_SETMASK:
p->p_sigmask = mask &~ sigcantmask; p->p_sigmask = mask;
sigminusset(&sigcantmask, &p->p_sigmask);
break; break;
default: default:
error = EINVAL; error = EINVAL;
@ -261,9 +275,8 @@ hpux_sys_sigpending(p, v, retval)
struct hpux_sys_sigpending_args *uap = v; struct hpux_sys_sigpending_args *uap = v;
hpux_sigset_t sigset; hpux_sigset_t sigset;
sigset.sigset[0] = bsdtohpuxmask(p->p_siglist); bsdtohpuxmask(&p->p_siglist, &sigset.sigset[0]);
return (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, set), return (copyout(&sigset, SCARG(uap, set), sizeof(sigset)));
sizeof(sigset)));
} }
int int
@ -273,19 +286,16 @@ hpux_sys_sigsuspend(p, v, retval)
register_t *retval; register_t *retval;
{ {
struct hpux_sys_sigsuspend_args *uap = v; struct hpux_sys_sigsuspend_args *uap = v;
struct sigacts *ps = p->p_sigacts;
hpux_sigset_t sigset; hpux_sigset_t sigset;
int mask; sigset_t mask;
int error;
if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset, sizeof(sigset))) error = copyin(SCARG(uap, set), &sigset, sizeof(sigset));
return (EFAULT); if (error)
mask = hpuxtobsdmask(sigset.sigset[0]); return (error);
ps->ps_oldmask = p->p_sigmask;
ps->ps_flags |= SAS_OLDMASK; hpuxtobsdmask(sigset.sigset[0], &mask);
p->p_sigmask = mask &~ sigcantmask; return (sigsuspend1(p, &mask));
(void) tsleep((caddr_t)ps, PPAUSE | PCATCH, "pause", 0);
/* always return EINTR rather than ERESTART... */
return (EINTR);
} }
int int
@ -298,54 +308,53 @@ hpux_sys_sigaction(p, v, retval)
struct hpux_sigaction action; struct hpux_sigaction action;
struct sigacts *ps = p->p_sigacts; struct sigacts *ps = p->p_sigacts;
struct hpux_sigaction *sa; struct hpux_sigaction *sa;
int sig; struct sigaction *bsa;
int bit; int sig, error;
sig = hpuxtobsdsig(SCARG(uap, signo)); sig = hpuxtobsdsig(SCARG(uap, signo));
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
return (EINVAL); return (EINVAL);
bsa = &ps->ps_sigact[sig];
sa = &action; sa = &action;
if (SCARG(uap, osa)) { if (SCARG(uap, osa)) {
sa->sa_handler = ps->ps_sigact[sig]; sa->sa_handler = bsa->sa_handler;
memset((caddr_t)&sa->sa_mask, 0, sizeof(sa->sa_mask)); memset((caddr_t)&sa->sa_mask, 0, sizeof(sa->sa_mask));
sa->sa_mask.sigset[0] = bsdtohpuxmask(ps->ps_catchmask[sig]); bsdtohpuxmask(&bsa->sa_mask, &sa->sa_mask.sigset[0]);
bit = sigmask(sig);
sa->sa_flags = 0; sa->sa_flags = 0;
if ((ps->ps_sigonstack & bit) != 0) if (bsa->sa_flags & SA_ONSTACK)
sa->sa_flags |= HPUXSA_ONSTACK; sa->sa_flags |= HPUXSA_ONSTACK;
if ((ps->ps_sigreset & bit) != 0) if (bsa->sa_flags & SA_RESETHAND)
sa->sa_flags |= HPUXSA_RESETHAND; sa->sa_flags |= HPUXSA_RESETHAND;
if (p->p_flag & P_NOCLDSTOP) if (bsa->sa_flags & SA_NOCLDSTOP)
sa->sa_flags |= HPUXSA_NOCLDSTOP; sa->sa_flags |= HPUXSA_NOCLDSTOP;
if (copyout((caddr_t)sa, (caddr_t)SCARG(uap, osa), error = copyout(sa, SCARG(uap, osa), sizeof (action));
sizeof (action))) if (error)
return (EFAULT); return (error);
} }
if (SCARG(uap, nsa)) { if (SCARG(uap, nsa)) {
struct sigaction act; struct sigaction act;
if (copyin((caddr_t)SCARG(uap, nsa), (caddr_t)sa, error = copyin(SCARG(uap, nsa), sa, sizeof(action));
sizeof (action))) if (error)
return (EFAULT); return (error);
if (sig == SIGCONT && sa->sa_handler == SIG_IGN) if (sig == SIGCONT && sa->sa_handler == SIG_IGN)
return (EINVAL); return (EINVAL);
/*
* Create a sigaction struct for setsigvec
*/
act.sa_handler = sa->sa_handler; act.sa_handler = sa->sa_handler;
act.sa_mask = hpuxtobsdmask(sa->sa_mask.sigset[0]); hpuxtobsdmask(sa->sa_mask.sigset[0], &act.sa_mask);
act.sa_flags = SA_RESTART; act.sa_flags = SA_RESTART;
if (sa->sa_flags & HPUXSA_ONSTACK) if (sa->sa_flags & HPUXSA_ONSTACK)
act.sa_flags |= SA_ONSTACK; act.sa_flags |= SA_ONSTACK;
if (sa->sa_flags & HPUXSA_RESETHAND)
act.sa_flags |= SA_RESETHAND;
if (sa->sa_flags & HPUXSA_NOCLDSTOP) if (sa->sa_flags & HPUXSA_NOCLDSTOP)
act.sa_flags |= SA_NOCLDSTOP; act.sa_flags |= SA_NOCLDSTOP;
setsigvec(p, sig, &act);
#if 0 error = sigaction1(p, sig, &act, NULL);
/* XXX -- SOUSIG no longer exists, do something here */ if (error)
if (sa->sa_flags & HPUXSA_RESETHAND) return (error);
p->p_flag |= SOUSIG; /* XXX */
#endif
} }
return (0); return (0);
} }
@ -364,6 +373,7 @@ hpux_sys_ssig_6x(p, v, retval)
struct sigaction vec; struct sigaction vec;
struct sigaction *sa = &vec; struct sigaction *sa = &vec;
memset(sa, 0, sizeof(*sa));
a = hpuxtobsdsig(SCARG(uap, signo)); a = hpuxtobsdsig(SCARG(uap, signo));
sa->sa_handler = SCARG(uap, fun); sa->sa_handler = SCARG(uap, fun);
/* /*
@ -379,10 +389,10 @@ hpux_sys_ssig_6x(p, v, retval)
if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP || if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
(a == SIGCONT && sa->sa_handler == SIG_IGN)) (a == SIGCONT && sa->sa_handler == SIG_IGN))
return (EINVAL); return (EINVAL);
sa->sa_mask = 0; sigemptyset(&sa->sa_mask);
sa->sa_flags = 0; sa->sa_flags = 0;
*retval = (int)p->p_sigacts->ps_sigact[a]; *retval = (register_t)p->p_sigacts->ps_sigact[a].sa_handler;
setsigvec(p, a, sa); sigaction1(p, a, sa, NULL);
#if 0 #if 0
p->p_flag |= SOUSIG; /* mark as simulating old stuff */ p->p_flag |= SOUSIG; /* mark as simulating old stuff */
#endif #endif
@ -410,32 +420,34 @@ bsdtohpuxsig(sig)
} }
/* signal masks: convert from HPUX to BSD (not pretty or fast) */ /* signal masks: convert from HPUX to BSD (not pretty or fast) */
int void
hpuxtobsdmask(mask) hpuxtobsdmask(hpuxmask, bsdmask)
int mask; int hpuxmask;
sigset_t *bsdmask;
{ {
int nmask, sig, nsig; int sig, nsig;
if (mask == 0 || mask == -1) sigemptyset(bsdmask);
return(mask);
nmask = 0; for (sig = 1; sig < NSIG; sig++) {
for (sig = 1; sig < NSIG; sig++) if ((hpuxmask & (1 << sig)) != 0 &&
if ((mask & sigmask(sig)) && (nsig = hpuxtobsdsig(sig))) (nsig = hpuxtobsdsig(sig)) != 0)
nmask |= sigmask(nsig); sigaddset(bsdmask, sig);
return(nmask); }
} }
int void
bsdtohpuxmask(mask) bsdtohpuxmask(bsdmask, hpuxmask)
int mask; const sigset_t *bsdmask;
int *hpuxmask;
{ {
int nmask, sig, nsig; int sig, nsig;
if (mask == 0 || mask == -1) *hpuxmask = 0;
return(mask);
nmask = 0; for (sig = 1; sig < NSIG; sig++) {
for (sig = 1; sig < NSIG; sig++) if (sigismember(bsdmask, sig) &&
if ((mask & sigmask(sig)) && (nsig = bsdtohpuxsig(sig))) (nsig = bsdtohpuxsig(sig)) != 0)
nmask |= sigmask(nsig); *hpuxmask |= (1 << sig);
return(nmask); }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_sig.h,v 1.1 1997/04/01 19:59:03 scottr Exp $ */ /* $NetBSD: hpux_sig.h,v 1.2 1998/10/01 06:35:10 thorpej Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -49,6 +49,6 @@
#ifdef _KERNEL #ifdef _KERNEL
int hpuxtobsdsig __P((int)); int hpuxtobsdsig __P((int));
int bsdtohpuxsig __P((int)); int bsdtohpuxsig __P((int));
int hpuxtobsdmask __P((int)); void hpuxtobsdmask __P((int, sigset_t *));
int bsdtohpuxmask __P((int)); void bsdtohpuxmask __P((const sigset_t *, int *));
#endif /* _KERNEL */ #endif /* _KERNEL */