* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* %sccs.include.redist.c%
* from: Utah $Hdr: hpux_sig.c 1.4 92/01/20$
* @(#)hpux_sig.c 8.3 (Berkeley) %G%
* Signal related HPUX compatibility routines
#include <sys/signalvar.h>
#include <hp/hpux/hpux.h>
/* indexed by HPUX signal number - 1 */
char hpuxtobsdsigmap
[NSIG
] = {
/*01*/ SIGHUP
, SIGINT
, SIGQUIT
, SIGILL
, SIGTRAP
, SIGIOT
, SIGEMT
, SIGFPE
,
/*09*/ SIGKILL
, SIGBUS
, SIGSEGV
, SIGSYS
, SIGPIPE
, SIGALRM
, SIGTERM
, SIGUSR1
,
/*17*/ SIGUSR2
, SIGCHLD
, 0, SIGVTALRM
,SIGPROF
, SIGIO
, SIGWINCH
, SIGSTOP
,
/*25*/ SIGTSTP
, SIGCONT
,SIGTTIN
, SIGTTOU
, SIGURG
, 0, 0, 0
/* indexed by BSD signal number - 1 */
char bsdtohpuxsigmap
[NSIG
] = {
/*01*/ 1, 2, 3, 4, 5, 6, 7, 8,
/*09*/ 9, 10, 11, 12, 13, 14, 15, 29,
/*17*/ 24, 25, 26, 18, 27, 28, 22, 0,
/*25*/ 0, 20, 21, 23, 0, 16, 17, 0
* 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.
hpuxsigvec(p
, uap
, retval
)
register struct hpuxsigvec_args
*uap
;
register struct sigacts
*ps
= p
->p_sigacts
;
register struct sigvec
*sv
;
sig
= hpuxtobsdsig(uap
->signo
);
if (sig
<= 0 || sig
>= NSIG
|| sig
== SIGKILL
|| sig
== SIGSTOP
)
sv
->sv_handler
= ps
->ps_sigact
[sig
];
sv
->sv_mask
= ps
->ps_catchmask
[sig
];
if ((ps
->ps_sigonstack
& bit
) != 0)
sv
->sv_flags
|= SV_ONSTACK
;
if ((ps
->ps_sigintr
& bit
) != 0)
sv
->sv_flags
|= SV_INTERRUPT
;
/* XXX -- SOUSIG no longer exists, do something here */
sv
->sv_flags
|= HPUXSV_RESET
; /* XXX */
error
= copyout((caddr_t
)sv
, (caddr_t
)uap
->osv
, sizeof (vec
));
error
= copyin((caddr_t
)uap
->nsv
, (caddr_t
)sv
, sizeof (vec
));
if (sig
== SIGCONT
&& sv
->sv_handler
== SIG_IGN
)
sv
->sv_flags
^= SA_RESTART
;
setsigvec(p
, sig
, (struct sigaction
*)sv
);
/* XXX -- SOUSIG no longer exists, do something here */
if (sv
->sv_flags
& HPUXSV_RESET
)
p
->p_flag
|= SOUSIG
; /* XXX */
struct hpuxsigblock_args
{
hpuxsigblock(p
, uap
, retval
)
struct hpuxsigblock_args
*uap
;
*retval
= bsdtohpuxmask(p
->p_sigmask
);
p
->p_sigmask
|= hpuxtobsdmask(uap
->mask
) &~ sigcantmask
;
struct hpuxsigsetmask_args
{
hpuxsigsetmask(p
, uap
, retval
)
struct hpuxsigsetmask_args
*uap
;
*retval
= bsdtohpuxmask(p
->p_sigmask
);
p
->p_sigmask
= hpuxtobsdmask(uap
->mask
) &~ sigcantmask
;
struct hpuxsigpause_args
{
hpuxsigpause(p
, uap
, retval
)
struct hpuxsigpause_args
*uap
;
uap
->mask
= hpuxtobsdmask(uap
->mask
);
return (sigsuspend(p
, uap
, retval
));
/* not totally correct, but close enuf' */
struct hpuxkill_args
*uap
;
uap
->signo
= hpuxtobsdsig(uap
->signo
);
return (kill(p
, uap
, retval
));
* 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.
struct hpuxsigprocmask_args
{
hpuxsigprocmask(p
, uap
, retval
)
struct hpuxsigprocmask_args
*uap
;
* Copy out old mask first to ensure no errors.
* (proc sigmask should not be changed if call fails for any reason)
bzero((caddr_t
)&sigset
, sizeof(sigset
));
sigset
.sigset
[0] = bsdtohpuxmask(p
->p_sigmask
);
if (copyout((caddr_t
)&sigset
, (caddr_t
)uap
->oset
, sizeof(sigset
)))
if (copyin((caddr_t
)uap
->set
, (caddr_t
)&sigset
, sizeof(sigset
)))
mask
= hpuxtobsdmask(sigset
.sigset
[0]);
p
->p_sigmask
|= mask
&~ sigcantmask
;
p
->p_sigmask
= mask
&~ sigcantmask
;
struct hpuxsigpending_args
{
hpuxsigpending(p
, uap
, retval
)
struct hpuxsigpending_args
*uap
;
sigset
.sigset
[0] = bsdtohpuxmask(p
->p_siglist
);
return (copyout((caddr_t
)&sigset
, (caddr_t
)uap
->set
, sizeof(sigset
)));
struct hpuxsigsuspend_args
{
hpuxsigsuspend(p
, uap
, retval
)
struct hpuxsigsuspend_args
*uap
;
register struct sigacts
*ps
= p
->p_sigacts
;
if (copyin((caddr_t
)uap
->set
, (caddr_t
)&sigset
, sizeof(sigset
)))
mask
= hpuxtobsdmask(sigset
.sigset
[0]);
ps
->ps_oldmask
= p
->p_sigmask
;
ps
->ps_flags
|= SAS_OLDMASK
;
p
->p_sigmask
= mask
&~ sigcantmask
;
(void) tsleep((caddr_t
)ps
, PPAUSE
| PCATCH
, "pause", 0);
/* always return EINTR rather than ERESTART... */
struct hpuxsigaction_args
{
struct hpuxsigaction
*nsa
;
struct hpuxsigaction
*osa
;
hpuxsigaction(p
, uap
, retval
)
register struct hpuxsigaction_args
*uap
;
struct hpuxsigaction action
;
register struct sigacts
*ps
= p
->p_sigacts
;
register struct hpuxsigaction
*sa
;
sig
= hpuxtobsdsig(uap
->signo
);
if (sig
<= 0 || sig
>= NSIG
|| sig
== SIGKILL
|| sig
== SIGSTOP
)
sa
->sa_handler
= ps
->ps_sigact
[sig
];
bzero((caddr_t
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
sa
->sa_mask
.sigset
[0] = bsdtohpuxmask(ps
->ps_catchmask
[sig
]);
if ((ps
->ps_sigonstack
& bit
) != 0)
sa
->sa_flags
|= HPUXSA_ONSTACK
;
/* XXX -- SOUSIG no longer exists, do something here */
sa
->sa_flags
|= HPUXSA_RESETHAND
; /* XXX */
if (p
->p_flag
& P_NOCLDSTOP
)
sa
->sa_flags
|= HPUXSA_NOCLDSTOP
;
if (copyout((caddr_t
)sa
, (caddr_t
)uap
->osa
, sizeof (action
)))
if (copyin((caddr_t
)uap
->nsa
, (caddr_t
)sa
, sizeof (action
)))
if (sig
== SIGCONT
&& sa
->sa_handler
== SIG_IGN
)
* Create a sigaction struct for setsigvec
act
.sa_handler
= sa
->sa_handler
;
act
.sa_mask
= hpuxtobsdmask(sa
->sa_mask
.sigset
[0]);
act
.sa_flags
== SA_RESTART
;
if (sa
->sa_flags
& HPUXSA_ONSTACK
)
act
.sa_flags
|= SA_ONSTACK
;
if (sa
->sa_flags
& HPUXSA_NOCLDSTOP
)
act
.sa_flags
|= SA_NOCLDSTOP
;
/* XXX -- SOUSIG no longer exists, do something here */
if (sa
->sa_flags
& HPUXSA_RESETHAND
)
p
->p_flag
|= SOUSIG
; /* XXX */
compat_43_hpuxssig(p
, uap
, retval
)
struct ohpuxssig_args
*uap
;
register struct sigaction
*sa
= &vec
;
a
= hpuxtobsdsig(uap
->signo
);
sa
->sa_handler
= uap
->fun
;
* Kill processes trying to use job control facilities
* (this'll help us find any vestiges of the old stuff).
(sa
->sa_handler
!= SIG_DFL
&& sa
->sa_handler
!= SIG_IGN
&&
((int)sa
->sa_handler
) & 1)) {
if (a
<= 0 || a
>= NSIG
|| a
== SIGKILL
|| a
== SIGSTOP
||
a
== SIGCONT
&& sa
->sa_handler
== SIG_IGN
)
*retval
= (int)p
->p_sigacts
->ps_sigact
[a
];
p
->p_flag
|= SOUSIG
; /* mark as simulating old stuff */
/* signal numbers: convert from HPUX to BSD */
if (--sig
< 0 || sig
>= NSIG
)
return((int)hpuxtobsdsigmap
[sig
]);
/* signal numbers: convert from BSD to HPUX */
if (--sig
< 0 || sig
>= NSIG
)
return((int)bsdtohpuxsigmap
[sig
]);
/* signal masks: convert from HPUX to BSD (not pretty or fast) */
register int nmask
, sig
, nsig
;
if (mask
== 0 || mask
== -1)
for (sig
= 1; sig
< NSIG
; sig
++)
if ((mask
& sigmask(sig
)) && (nsig
= hpuxtobsdsig(sig
)))
register int nmask
, sig
, nsig
;
if (mask
== 0 || mask
== -1)
for (sig
= 1; sig
< NSIG
; sig
++)
if ((mask
& sigmask(sig
)) && (nsig
= bsdtohpuxsig(sig
)))