#ifndef _SYS_SIGNALVAR_H_
#define _SYS_SIGNALVAR_H_
#include <sys/siginfo.h>
#include <sys/queue.h>
#include <sys/mutex.h>
#include <sys/stdbool.h>
#ifndef _KERNEL
#include <string.h>
#endif
typedef TAILQ_HEAD(ksiginfoq, ksiginfo) ksiginfoq_t;
struct sigacts {
struct sigact_sigdesc {
struct sigaction sd_sigact;
const void *sd_tramp;
int sd_vers;
} sa_sigdesc[NSIG];
int sa_refcnt;
kmutex_t sa_mutex;
};
typedef struct sigpend {
ksiginfoq_t sp_info;
sigset_t sp_set;
} sigpend_t;
struct sigctx {
struct _ksiginfo ps_info;
int ps_lwp;
bool ps_faked;
void *ps_sigcode;
sigset_t ps_sigignore;
sigset_t ps_sigcatch;
sigset_t ps_sigpass;
};
#define SIG_CATCH (void (*)(int))2
#define SIGACTION(p, sig) (p->p_sigacts->sa_sigdesc[(sig)].sd_sigact)
#define SIGACTION_PS(ps, sig) (ps->sa_sigdesc[(sig)].sd_sigact)
static __inline void
sigaction_copy(struct sigaction *dst, const struct sigaction *src)
{
memset(dst, 0, sizeof(*dst));
dst->_sa_u._sa_handler = src->_sa_u._sa_handler;
memcpy(&dst->sa_mask, &src->sa_mask, sizeof(dst->sa_mask));
dst->sa_flags = src->sa_flags;
}
#define SA_KILL 0x0001
#define SA_CORE 0x0002
#define SA_STOP 0x0004
#define SA_TTYSTOP 0x0008
#define SA_IGNORE 0x0010
#define SA_CONT 0x0020
#define SA_CANTMASK 0x0040
#define SA_NORESET 0x0080
#define SA_TOLWP 0x0100
#define SA_TOALL 0x0200
#ifdef _KERNEL
#include <sys/systm.h>
extern sigset_t contsigmask, stopsigmask, sigcantmask;
struct vnode;
struct coredump_iostate;
int coredump_netbsd(struct lwp *, struct coredump_iostate *);
int coredump_netbsd32(struct lwp *, struct coredump_iostate *);
int real_coredump_netbsd(struct lwp *, struct coredump_iostate *);
void execsigs(struct proc *);
int issignal(struct lwp *);
void pgsignal(struct pgrp *, int, int);
void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
void postsig(int);
void psignal(struct proc *, int);
void kpsignal(struct proc *, struct ksiginfo *, void *);
void child_psignal(struct proc *, int);
void siginit(struct proc *);
void trapsignal(struct lwp *, struct ksiginfo *);
void sigexit(struct lwp *, int) __dead;
void killproc(struct proc *, const char *);
void setsigvec(struct proc *, int, struct sigaction *);
int killpg1(struct lwp *, struct ksiginfo *, int, int);
void proc_unstop(struct proc *p);
void eventswitch(int, int, int);
void eventswitchchild(struct proc *, int, int);
int sigaction1(struct lwp *, int, const struct sigaction *,
struct sigaction *, const void *, int);
int sigprocmask1(struct lwp *, int, const sigset_t *, sigset_t *);
void sigpending1(struct lwp *, sigset_t *);
void sigsuspendsetup(struct lwp *, const sigset_t *);
void sigsuspendteardown(struct lwp *);
int sigsuspend1(struct lwp *, const sigset_t *);
int sigaltstack1(struct lwp *, const stack_t *, stack_t *);
int sigismasked(struct lwp *, int);
int sigget(sigpend_t *, ksiginfo_t *, int, const sigset_t *);
void sigclear(sigpend_t *, const sigset_t *, ksiginfoq_t *);
void sigclearall(struct proc *, const sigset_t *, ksiginfoq_t *);
int kpsignal2(struct proc *, ksiginfo_t *);
void signal_init(void);
struct sigacts *sigactsinit(struct proc *, int);
void sigactsunshare(struct proc *);
void sigactsfree(struct sigacts *);
void kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *);
void sendsig_reset(struct lwp *, int);
void sendsig(const struct ksiginfo *, const sigset_t *);
ksiginfo_t *ksiginfo_alloc(struct proc *, ksiginfo_t *, int);
void ksiginfo_free(ksiginfo_t *);
void ksiginfo_queue_drain0(ksiginfoq_t *);
struct sys_____sigtimedwait50_args;
int sigtimedwait1(struct lwp *, const struct sys_____sigtimedwait50_args *,
register_t *, copyin_t, copyout_t, copyin_t, copyout_t);
void signotify(struct lwp *);
int sigispending(struct lwp *, int);
void sendsig_sigcontext(const struct ksiginfo *, const sigset_t *);
void sendsig_siginfo(const struct ksiginfo *, const sigset_t *);
extern struct pool ksiginfo_pool;
static __inline int
firstsig(const sigset_t *ss)
{
int sig;
sig = ffs(ss->__bits[0]);
if (sig != 0)
return (sig);
#if NSIG > 33
sig = ffs(ss->__bits[1]);
if (sig != 0)
return (sig + 32);
#endif
#if NSIG > 65
sig = ffs(ss->__bits[2]);
if (sig != 0)
return (sig + 64);
#endif
#if NSIG > 97
sig = ffs(ss->__bits[3]);
if (sig != 0)
return (sig + 96);
#endif
return (0);
}
static __inline void
ksiginfo_queue_init(ksiginfoq_t *kq)
{
TAILQ_INIT(kq);
}
static __inline void
ksiginfo_queue_drain(ksiginfoq_t *kq)
{
if (!TAILQ_EMPTY(kq))
ksiginfo_queue_drain0(kq);
}
#endif
#ifdef _KERNEL
#ifdef SIGPROP
const int sigprop[NSIG] = {
0,
SA_KILL,
SA_KILL,
SA_KILL|SA_CORE,
SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,
SA_KILL|SA_CORE|SA_NORESET|SA_TOLWP,
SA_KILL|SA_CORE,
SA_KILL|SA_CORE|SA_TOLWP,
SA_KILL|SA_CORE|SA_TOLWP,
SA_KILL|SA_CANTMASK|SA_TOALL,
SA_KILL|SA_CORE|SA_TOLWP,
SA_KILL|SA_CORE|SA_TOLWP,
SA_KILL|SA_CORE|SA_TOLWP,
SA_KILL,
SA_KILL,
SA_KILL,
SA_IGNORE,
SA_STOP|SA_CANTMASK|SA_TOALL,
SA_STOP|SA_TTYSTOP|SA_TOALL,
SA_IGNORE|SA_CONT|SA_TOALL,
SA_IGNORE,
SA_STOP|SA_TTYSTOP|SA_TOALL,
SA_STOP|SA_TTYSTOP|SA_TOALL,
SA_IGNORE,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_IGNORE,
SA_IGNORE,
SA_KILL,
SA_KILL,
SA_IGNORE|SA_NORESET,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
SA_KILL,
};
#undef SIGPROP
#else
extern const int sigprop[NSIG];
#endif
#endif
#endif