2002-07-05 03:32:02 +04:00
|
|
|
/* $NetBSD: hpux_sig.c,v 1.23 2002/07/04 23:32:09 thorpej Exp $ */
|
1994-10-26 05:45:11 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988 University of Utah.
|
1994-05-23 12:03:32 +04:00
|
|
|
* Copyright (c) 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* 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. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
|
|
|
*
|
1994-05-23 12:03:32 +04:00
|
|
|
* from: Utah $Hdr: hpux_sig.c 1.4 92/01/20$
|
|
|
|
*
|
1994-10-26 05:45:11 +03:00
|
|
|
* @(#)hpux_sig.c 8.2 (Berkeley) 9/23/93
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Signal related HPUX compatibility routines
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-07-05 03:32:02 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: hpux_sig.c,v 1.23 2002/07/04 23:32:09 thorpej Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1994-05-23 12:03:32 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1997-04-01 23:58:58 +04:00
|
|
|
#include <sys/mount.h>
|
1994-05-23 12:03:32 +04:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/signalvar.h>
|
1997-04-01 23:58:58 +04:00
|
|
|
#include <sys/syscallargs.h>
|
1994-05-23 12:03:32 +04:00
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
#include <compat/hpux/hpux.h>
|
1997-04-01 23:58:58 +04:00
|
|
|
#include <compat/hpux/hpux_sig.h>
|
1995-05-10 20:45:25 +04:00
|
|
|
#include <compat/hpux/hpux_syscallargs.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
2002-04-01 02:22:43 +04:00
|
|
|
extern const unsigned char native_to_hpux_signo[];
|
|
|
|
extern const unsigned char hpux_to_native_signo[];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: In addition to mapping the signal number we also have
|
|
|
|
* to see if the "old" style signal mechinism is needed.
|
|
|
|
* If so, we set the OUSIG flag. This is not really correct
|
|
|
|
* as under HP-UX "old" style handling can be set on a per
|
|
|
|
* signal basis and we are setting it for all signals in one
|
|
|
|
* swell foop. I suspect we can get away with this since I
|
|
|
|
* doubt any program of interest mixes the two semantics.
|
|
|
|
*/
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigvec(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-04-01 23:58:58 +04:00
|
|
|
struct hpux_sys_sigvec_args *uap = v;
|
1998-10-01 10:35:09 +04:00
|
|
|
struct sigvec nsv, osv;
|
|
|
|
struct sigaction nsa, osa;
|
|
|
|
int sig, 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!
|
|
|
|
*/
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-10-20 07:47:31 +03:00
|
|
|
sig = hpuxtobsdsig(SCARG(uap, signo));
|
1993-05-13 17:56:20 +04:00
|
|
|
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
|
|
|
|
return (EINVAL);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
|
|
|
if (SCARG(uap, nsv)) {
|
|
|
|
error = copyin(SCARG(uap, nsv), &nsv, sizeof(nsv));
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
|
|
|
compat_43_sigvec_to_sigaction(&nsv, &nsa);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1998-10-01 10:35:09 +04:00
|
|
|
|
|
|
|
error = sigaction1(p, sig,
|
|
|
|
SCARG(uap, nsv) ? &nsa : NULL,
|
2002-07-05 03:32:02 +04:00
|
|
|
SCARG(uap, osv) ? &osa : NULL,
|
|
|
|
NULL, 0);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if (SCARG(uap, osv)) {
|
|
|
|
compat_43_sigaction_to_sigvec(&osa, &osv);
|
|
|
|
error = copyout(&osv, SCARG(uap, osv), sizeof(osv));
|
1993-05-13 17:56:20 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
1998-10-01 10:35:09 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigblock(p, v, retval)
|
1997-04-01 23:58:58 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigblock_args *uap = v;
|
1998-10-01 10:35:09 +04:00
|
|
|
sigset_t nmask;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
2000-08-21 06:31:59 +04:00
|
|
|
(void) splsched();
|
1998-10-01 10:35:09 +04:00
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
bsdtohpuxmask(&p->p_sigctx.ps_sigmask, (int *)retval);
|
1998-10-01 10:35:09 +04:00
|
|
|
hpuxtobsdmask(SCARG(uap, mask), &nmask);
|
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
sigplusset(&nmask, &p->p_sigctx.ps_sigmask);
|
|
|
|
sigminusset(&sigcantmask, &p->p_sigctx.ps_sigmask);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) spl0();
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigsetmask(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigsetmask_args *uap = v;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
2000-08-21 06:31:59 +04:00
|
|
|
(void) splsched();
|
1998-10-01 10:35:09 +04:00
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
bsdtohpuxmask(&p->p_sigctx.ps_sigmask, (int *)retval);
|
|
|
|
hpuxtobsdmask(SCARG(uap, mask), &p->p_sigctx.ps_sigmask);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
sigminusset(&sigcantmask, &p->p_sigctx.ps_sigmask);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) spl0();
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigpause(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigpause_args *uap = v;
|
1998-10-01 10:35:09 +04:00
|
|
|
sigset_t mask;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1998-10-01 10:35:09 +04:00
|
|
|
hpuxtobsdmask(SCARG(uap, mask), &mask);
|
|
|
|
return (sigsuspend1(p, &mask));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* not totally correct, but close enuf' */
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_kill(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_kill_args *uap = v;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-10-20 07:47:31 +03:00
|
|
|
if (SCARG(uap, signo)) {
|
|
|
|
SCARG(uap, signo) = hpuxtobsdsig(SCARG(uap, signo));
|
|
|
|
if (SCARG(uap, signo) == 0)
|
|
|
|
SCARG(uap, signo) = NSIG;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-10-07 09:25:19 +03:00
|
|
|
return (sys_kill(p, uap, retval));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following (sigprocmask, sigpending, sigsuspend, sigaction are
|
|
|
|
* POSIX calls. Under BSD, the library routine dereferences the sigset_t
|
|
|
|
* pointers before traping. Not so under HP-UX.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Manipulate signal mask.
|
|
|
|
* Note that we receive new mask, not pointer,
|
|
|
|
* and return old mask as return value;
|
|
|
|
* the library stub does the rest.
|
1998-10-01 10:35:09 +04:00
|
|
|
*
|
|
|
|
* XXX We don't handle all HP-UX signals!
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigprocmask(p, v, retval)
|
1997-04-01 23:58:58 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigprocmask_args *uap = v;
|
1998-10-01 10:35:09 +04:00
|
|
|
int error = 0;
|
1994-01-07 03:43:39 +03:00
|
|
|
hpux_sigset_t sigset;
|
1998-10-01 10:35:09 +04:00
|
|
|
sigset_t mask;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy out old mask first to ensure no errors.
|
|
|
|
* (proc sigmask should not be changed if call fails for any reason)
|
|
|
|
*/
|
1994-10-20 07:47:31 +03:00
|
|
|
if (SCARG(uap, oset)) {
|
1998-08-10 00:36:58 +04:00
|
|
|
memset((caddr_t)&sigset, 0, sizeof(sigset));
|
2000-12-28 00:58:52 +03:00
|
|
|
bsdtohpuxmask(&p->p_sigctx.ps_sigmask, &sigset.sigset[0]);
|
1998-10-01 10:35:09 +04:00
|
|
|
error = copyout(&sigset, SCARG(uap, oset), sizeof(sigset));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1994-10-20 07:47:31 +03:00
|
|
|
if (SCARG(uap, set)) {
|
1998-10-01 10:35:09 +04:00
|
|
|
error = copyin(SCARG(uap, set), &sigset, sizeof(sigset));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
hpuxtobsdmask(sigset.sigset[0], &mask);
|
2000-08-21 06:31:59 +04:00
|
|
|
(void) splsched();
|
1994-10-20 07:47:31 +03:00
|
|
|
switch (SCARG(uap, how)) {
|
1993-05-13 17:56:20 +04:00
|
|
|
case HPUXSIG_BLOCK:
|
2000-12-28 00:58:52 +03:00
|
|
|
sigplusset(&mask, &p->p_sigctx.ps_sigmask);
|
|
|
|
sigminusset(&sigcantmask, &p->p_sigctx.ps_sigmask);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
case HPUXSIG_UNBLOCK:
|
2000-12-28 00:58:52 +03:00
|
|
|
sigminusset(&mask, &p->p_sigctx.ps_sigmask);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
case HPUXSIG_SETMASK:
|
2000-12-28 00:58:52 +03:00
|
|
|
p->p_sigctx.ps_sigmask = mask;
|
|
|
|
sigminusset(&sigcantmask, &p->p_sigctx.ps_sigmask);
|
1993-05-13 17:56:20 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
(void) spl0();
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigpending(p, v, retval)
|
1997-04-01 23:58:58 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigpending_args *uap = v;
|
1994-01-07 03:43:39 +03:00
|
|
|
hpux_sigset_t sigset;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
bsdtohpuxmask(&p->p_sigctx.ps_siglist, &sigset.sigset[0]);
|
1998-10-01 10:35:09 +04:00
|
|
|
return (copyout(&sigset, SCARG(uap, set), sizeof(sigset)));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigsuspend(p, v, retval)
|
1997-04-01 23:58:58 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct hpux_sys_sigsuspend_args *uap = v;
|
1994-01-07 03:43:39 +03:00
|
|
|
hpux_sigset_t sigset;
|
1998-10-01 10:35:09 +04:00
|
|
|
sigset_t mask;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = copyin(SCARG(uap, set), &sigset, sizeof(sigset));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
hpuxtobsdmask(sigset.sigset[0], &mask);
|
|
|
|
return (sigsuspend1(p, &mask));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
hpux_sys_sigaction(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-04-01 23:58:58 +04:00
|
|
|
struct hpux_sys_sigaction_args *uap = v;
|
1994-01-07 03:43:39 +03:00
|
|
|
struct hpux_sigaction action;
|
1997-04-01 23:58:58 +04:00
|
|
|
struct hpux_sigaction *sa;
|
1998-10-01 10:35:09 +04:00
|
|
|
struct sigaction *bsa;
|
|
|
|
int sig, error;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-10-20 07:47:31 +03:00
|
|
|
sig = hpuxtobsdsig(SCARG(uap, signo));
|
1993-05-13 17:56:20 +04:00
|
|
|
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2000-12-28 00:58:52 +03:00
|
|
|
bsa = &SIGACTION(p, sig);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
sa = &action;
|
1994-10-20 07:47:31 +03:00
|
|
|
if (SCARG(uap, osa)) {
|
1998-10-01 10:35:09 +04:00
|
|
|
sa->sa_handler = bsa->sa_handler;
|
1998-08-10 00:36:58 +04:00
|
|
|
memset((caddr_t)&sa->sa_mask, 0, sizeof(sa->sa_mask));
|
1998-10-01 10:35:09 +04:00
|
|
|
bsdtohpuxmask(&bsa->sa_mask, &sa->sa_mask.sigset[0]);
|
1993-05-13 17:56:20 +04:00
|
|
|
sa->sa_flags = 0;
|
1998-10-01 10:35:09 +04:00
|
|
|
if (bsa->sa_flags & SA_ONSTACK)
|
1993-05-13 17:56:20 +04:00
|
|
|
sa->sa_flags |= HPUXSA_ONSTACK;
|
1998-10-01 10:35:09 +04:00
|
|
|
if (bsa->sa_flags & SA_RESETHAND)
|
1995-10-07 09:25:19 +03:00
|
|
|
sa->sa_flags |= HPUXSA_RESETHAND;
|
1998-10-01 10:35:09 +04:00
|
|
|
if (bsa->sa_flags & SA_NOCLDSTOP)
|
1993-05-13 17:56:20 +04:00
|
|
|
sa->sa_flags |= HPUXSA_NOCLDSTOP;
|
1998-10-01 10:35:09 +04:00
|
|
|
error = copyout(sa, SCARG(uap, osa), sizeof (action));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1994-10-20 07:47:31 +03:00
|
|
|
if (SCARG(uap, nsa)) {
|
1993-05-13 17:56:20 +04:00
|
|
|
struct sigaction act;
|
|
|
|
|
1998-10-01 10:35:09 +04:00
|
|
|
error = copyin(SCARG(uap, nsa), sa, sizeof(action));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (sig == SIGCONT && sa->sa_handler == SIG_IGN)
|
|
|
|
return (EINVAL);
|
1998-10-01 10:35:09 +04:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
act.sa_handler = sa->sa_handler;
|
1998-10-01 10:35:09 +04:00
|
|
|
hpuxtobsdmask(sa->sa_mask.sigset[0], &act.sa_mask);
|
1997-04-01 23:58:58 +04:00
|
|
|
act.sa_flags = SA_RESTART;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (sa->sa_flags & HPUXSA_ONSTACK)
|
|
|
|
act.sa_flags |= SA_ONSTACK;
|
1998-10-01 10:35:09 +04:00
|
|
|
if (sa->sa_flags & HPUXSA_RESETHAND)
|
|
|
|
act.sa_flags |= SA_RESETHAND;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (sa->sa_flags & HPUXSA_NOCLDSTOP)
|
|
|
|
act.sa_flags |= SA_NOCLDSTOP;
|
1998-10-01 10:35:09 +04:00
|
|
|
|
2002-07-05 03:32:02 +04:00
|
|
|
error = sigaction1(p, sig, &act, NULL, NULL, 0);
|
1998-10-01 10:35:09 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
Get COMPAT_HPUX partially working on the hp300. Notable improvements:
* It compiles (and links).
* Make use of "/emul/hpux" where applicable.
* Untangle a bit, pulling some funtions from the monolithic
hpux_compat.c into hpux_file.c, hpux_exec.c, etc.
* Fix a couple of bugs.
Yet to do:
* Move hp300-specific functions into hp300/hp300/hpux_machdep.c.
* Make everything work properly (you laugh...)
These changes are sufficient to run some simple HP-UX 9.x executables,
including ls(1) (which will read password and group information from the
YP server correctly, albeit slowly), a simple "hello world", uname(1),
and a few other odds and ends. Dynamically linked executables work, and
demand-paging _seems_ to work properly. Major problems:
* socket and/or signal handling appears to need some work yet.
* 99% sure I didn't do exactly the right thing adjusting for the
fact that "kstack" is gone now.
* ktrace(1)'ing some executables (HP-UX telnet(1) is what I tried)
causes the HP-UX executable to dump core with a SIGSEGV for an
as of yet unknown reason.
This is mostly meant as a checkpoint/snapshot, to make it easier for others
to track progress on this code, and hack on it themselves. It's certainly
better off now than before.
1995-11-28 11:39:45 +03:00
|
|
|
hpux_sys_ssig_6x(p, v, retval)
|
1993-05-13 17:56:20 +04:00
|
|
|
struct proc *p;
|
1995-09-20 02:53:47 +04:00
|
|
|
void *v;
|
1994-10-20 07:47:31 +03:00
|
|
|
register_t *retval;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
Get COMPAT_HPUX partially working on the hp300. Notable improvements:
* It compiles (and links).
* Make use of "/emul/hpux" where applicable.
* Untangle a bit, pulling some funtions from the monolithic
hpux_compat.c into hpux_file.c, hpux_exec.c, etc.
* Fix a couple of bugs.
Yet to do:
* Move hp300-specific functions into hp300/hp300/hpux_machdep.c.
* Make everything work properly (you laugh...)
These changes are sufficient to run some simple HP-UX 9.x executables,
including ls(1) (which will read password and group information from the
YP server correctly, albeit slowly), a simple "hello world", uname(1),
and a few other odds and ends. Dynamically linked executables work, and
demand-paging _seems_ to work properly. Major problems:
* socket and/or signal handling appears to need some work yet.
* 99% sure I didn't do exactly the right thing adjusting for the
fact that "kstack" is gone now.
* ktrace(1)'ing some executables (HP-UX telnet(1) is what I tried)
causes the HP-UX executable to dump core with a SIGSEGV for an
as of yet unknown reason.
This is mostly meant as a checkpoint/snapshot, to make it easier for others
to track progress on this code, and hack on it themselves. It's certainly
better off now than before.
1995-11-28 11:39:45 +03:00
|
|
|
struct hpux_sys_ssig_6x_args /* {
|
|
|
|
syscallarg(int) signo;
|
|
|
|
syscallarg(sig_t) fun;
|
|
|
|
} */ *uap = v;
|
1997-04-01 23:58:58 +04:00
|
|
|
int a;
|
1993-05-13 17:56:20 +04:00
|
|
|
struct sigaction vec;
|
1997-04-01 23:58:58 +04:00
|
|
|
struct sigaction *sa = &vec;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1998-10-01 10:35:09 +04:00
|
|
|
memset(sa, 0, sizeof(*sa));
|
1994-10-20 07:47:31 +03:00
|
|
|
a = hpuxtobsdsig(SCARG(uap, signo));
|
|
|
|
sa->sa_handler = SCARG(uap, fun);
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
|
|
|
* Kill processes trying to use job control facilities
|
|
|
|
* (this'll help us find any vestiges of the old stuff).
|
|
|
|
*/
|
|
|
|
if ((a &~ 0377) ||
|
|
|
|
(sa->sa_handler != SIG_DFL && sa->sa_handler != SIG_IGN &&
|
|
|
|
((int)sa->sa_handler) & 1)) {
|
|
|
|
psignal(p, SIGSYS);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
|
1997-04-01 23:58:58 +04:00
|
|
|
(a == SIGCONT && sa->sa_handler == SIG_IGN))
|
1993-05-13 17:56:20 +04:00
|
|
|
return (EINVAL);
|
1998-10-01 10:35:09 +04:00
|
|
|
sigemptyset(&sa->sa_mask);
|
1993-05-13 17:56:20 +04:00
|
|
|
sa->sa_flags = 0;
|
2000-12-28 00:58:52 +03:00
|
|
|
*retval = (register_t)SIGACTION(p, a).sa_handler;
|
2002-07-05 03:32:02 +04:00
|
|
|
sigaction1(p, a, sa, NULL, NULL, 0);
|
1993-05-13 17:56:20 +04:00
|
|
|
#if 0
|
|
|
|
p->p_flag |= SOUSIG; /* mark as simulating old stuff */
|
|
|
|
#endif
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* signal numbers: convert from HPUX to BSD */
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpuxtobsdsig(sig)
|
1997-04-01 23:58:58 +04:00
|
|
|
int sig;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
2002-04-01 02:22:43 +04:00
|
|
|
if (sig < 0 || sig >= NSIG)
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
2002-04-01 02:22:43 +04:00
|
|
|
return hpux_to_native_signo[sig];
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signal numbers: convert from BSD to HPUX */
|
1995-05-10 20:45:25 +04:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
bsdtohpuxsig(sig)
|
1997-04-01 23:58:58 +04:00
|
|
|
int sig;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
2002-04-01 02:22:43 +04:00
|
|
|
if (sig < 0 || sig >= NSIG)
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
2002-04-01 02:22:43 +04:00
|
|
|
return native_to_hpux_signo[sig];
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* signal masks: convert from HPUX to BSD (not pretty or fast) */
|
1998-10-01 10:35:09 +04:00
|
|
|
void
|
|
|
|
hpuxtobsdmask(hpuxmask, bsdmask)
|
|
|
|
int hpuxmask;
|
|
|
|
sigset_t *bsdmask;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1998-10-01 10:35:09 +04:00
|
|
|
int sig, nsig;
|
|
|
|
|
|
|
|
sigemptyset(bsdmask);
|
|
|
|
|
|
|
|
for (sig = 1; sig < NSIG; sig++) {
|
|
|
|
if ((hpuxmask & (1 << sig)) != 0 &&
|
|
|
|
(nsig = hpuxtobsdsig(sig)) != 0)
|
|
|
|
sigaddset(bsdmask, sig);
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 10:35:09 +04:00
|
|
|
void
|
|
|
|
bsdtohpuxmask(bsdmask, hpuxmask)
|
|
|
|
const sigset_t *bsdmask;
|
|
|
|
int *hpuxmask;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1998-10-01 10:35:09 +04:00
|
|
|
int sig, nsig;
|
|
|
|
|
|
|
|
*hpuxmask = 0;
|
|
|
|
|
|
|
|
for (sig = 1; sig < NSIG; sig++) {
|
|
|
|
if (sigismember(bsdmask, sig) &&
|
|
|
|
(nsig = bsdtohpuxsig(sig)) != 0)
|
|
|
|
*hpuxmask |= (1 << sig);
|
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|