ksh: Drop support for OSes without POSIX sigaction(2)
This commit is contained in:
parent
2537c199ea
commit
a5a27bbf6f
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: Makefile,v 1.33 2016/03/16 23:02:23 christos Exp $
|
# $NetBSD: Makefile,v 1.34 2017/06/30 04:22:22 kamil Exp $
|
||||||
|
|
||||||
WARNS=3
|
WARNS=3
|
||||||
CWARNFLAGS.clang+= -Wno-error=cast-qual
|
CWARNFLAGS.clang+= -Wno-error=cast-qual
|
||||||
|
@ -10,8 +10,8 @@ CPPFLAGS+= -I.
|
||||||
PROG= ksh
|
PROG= ksh
|
||||||
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c \
|
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c \
|
||||||
eval.c exec.c expr.c history.c io.c jobs.c lex.c mail.c \
|
eval.c exec.c expr.c history.c io.c jobs.c lex.c mail.c \
|
||||||
main.c misc.c path.c shf.c sigact.c syn.c table.c trap.c \
|
main.c misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c \
|
||||||
tree.c tty.c var.c version.c vi.c
|
var.c version.c vi.c
|
||||||
DPSRCS= emacs.out siglist.out
|
DPSRCS= emacs.out siglist.out
|
||||||
.if (${MKMAN} != "no")
|
.if (${MKMAN} != "no")
|
||||||
DPSRCS+=ksh.1
|
DPSRCS+=ksh.1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: config.h,v 1.52 2017/06/30 04:11:57 kamil Exp $ */
|
/* $NetBSD: config.h,v 1.53 2017/06/30 04:22:22 kamil Exp $ */
|
||||||
|
|
||||||
/* config.h. Generated automatically by configure. */
|
/* config.h. Generated automatically by configure. */
|
||||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||||
|
@ -30,9 +30,6 @@
|
||||||
/* Define as the return value of signal handlers (0 or ). */
|
/* Define as the return value of signal handlers (0 or ). */
|
||||||
#define RETSIGVAL
|
#define RETSIGVAL
|
||||||
|
|
||||||
/* Define to use the fake posix signal routines (sigact.[ch]) */
|
|
||||||
/* #undef USE_FAKE_SIGACT */
|
|
||||||
|
|
||||||
/* Define if you have bsd versions of the setpgrp() and getpgrp() routines */
|
/* Define if you have bsd versions of the setpgrp() and getpgrp() routines */
|
||||||
/* #undef BSD_PGRP */
|
/* #undef BSD_PGRP */
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* $NetBSD: sh.h,v 1.31 2017/06/30 02:51:14 kamil Exp $ */
|
/* $NetBSD: sh.h,v 1.32 2017/06/30 04:22:22 kamil Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public Domain Bourne/Korn shell
|
* Public Domain Bourne/Korn shell
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: sh.h,v 1.31 2017/06/30 02:51:14 kamil Exp $ */
|
/* $Id: sh.h,v 1.32 2017/06/30 04:22:22 kamil Exp $ */
|
||||||
|
|
||||||
#include "config.h" /* system and option configuration info */
|
#include "config.h" /* system and option configuration info */
|
||||||
|
|
||||||
|
@ -80,10 +80,6 @@
|
||||||
|
|
||||||
typedef RETSIGTYPE (*handler_t) ARGS((int)); /* signal handler */
|
typedef RETSIGTYPE (*handler_t) ARGS((int)); /* signal handler */
|
||||||
|
|
||||||
#ifdef USE_FAKE_SIGACT
|
|
||||||
# include "sigact.h" /* use sjg's fake sigaction() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PATHS_H
|
#ifdef HAVE_PATHS_H
|
||||||
# include <paths.h>
|
# include <paths.h>
|
||||||
#endif /* HAVE_PATHS_H */
|
#endif /* HAVE_PATHS_H */
|
||||||
|
|
455
bin/ksh/sigact.c
455
bin/ksh/sigact.c
|
@ -1,455 +0,0 @@
|
||||||
/* $NetBSD: sigact.c,v 1.7 2017/06/23 00:07:15 kamil Exp $ */
|
|
||||||
|
|
||||||
/* NAME:
|
|
||||||
* sigact.c - fake sigaction(2)
|
|
||||||
*
|
|
||||||
* SYNOPSIS:
|
|
||||||
* #include "sigact.h"
|
|
||||||
*
|
|
||||||
* int sigaction(int sig, struct sigaction *act,
|
|
||||||
* struct sigaction *oact);
|
|
||||||
* int sigaddset(sigset_t *mask, int sig);
|
|
||||||
* int sigdelset(sigset_t *mask, int sig);
|
|
||||||
* int sigemptyset(sigset_t *mask);
|
|
||||||
* int sigfillset(sigset_t *mask);
|
|
||||||
* int sigismember(sigset_t *mask, int sig);
|
|
||||||
* int sigpending(sigset_t *set);
|
|
||||||
* int sigprocmask(int how, sigset_t *set, sigset_t *oset);
|
|
||||||
* int sigsuspend(sigset_t *mask);
|
|
||||||
*
|
|
||||||
* RETSIGTYPE (*Signal(int sig, RETSIGTYPE (*disp)(int)))(int);
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
* This is a fake sigaction implementation. It uses
|
|
||||||
* sigsetmask(2) et al or sigset(2) and friends if
|
|
||||||
* available, otherwise it just uses signal(2). If it
|
|
||||||
* thinks sigaction(2) really exists it compiles to "almost"
|
|
||||||
* nothing.
|
|
||||||
*
|
|
||||||
* In any case it provides a Signal() function that is
|
|
||||||
* implemented in terms of sigaction().
|
|
||||||
* If not using signal(2) as part of the underlying
|
|
||||||
* implementation (USE_SIGNAL or USE_SIGMASK), and
|
|
||||||
* NO_SIGNAL is not defined, it also provides a signal()
|
|
||||||
* function that calls Signal().
|
|
||||||
*
|
|
||||||
* The need for all this mucking about is the problems
|
|
||||||
* caused by mixing various signal handling mechanisms in
|
|
||||||
* the one process. This module allows for a consistent
|
|
||||||
* POSIX compliant interface to whatever is actually
|
|
||||||
* available.
|
|
||||||
*
|
|
||||||
* sigaction() allows the caller to examine and/or set the
|
|
||||||
* action to be associated with a given signal. "act" and
|
|
||||||
* "oact" are pointers to 'sigaction structs':
|
|
||||||
*.nf
|
|
||||||
*
|
|
||||||
* struct sigaction
|
|
||||||
* {
|
|
||||||
* RETSIGTYPE (*sa_handler)();
|
|
||||||
* sigset_t sa_mask;
|
|
||||||
* int sa_flags;
|
|
||||||
* };
|
|
||||||
*.fi
|
|
||||||
*
|
|
||||||
* RETSIGTYPE is normally 'void' in the POSIX implementation
|
|
||||||
* and for most current systems. On some older UNIX
|
|
||||||
* systems, signal handlers do not return 'void', so
|
|
||||||
* this implementation keeps 'sa_handler' inline with the
|
|
||||||
* hosts normal signal handling conventions.
|
|
||||||
* 'sa_mask' controls which signals will be blocked while
|
|
||||||
* the selected signal handler is active. It is not used
|
|
||||||
* in this implementation.
|
|
||||||
* 'sa_flags' controls various semantics such as whether
|
|
||||||
* system calls should be automagically restarted
|
|
||||||
* (SA_RESTART) etc. It is not used in this
|
|
||||||
* implementation.
|
|
||||||
* Either "act" or "oact" may be NULL in which case the
|
|
||||||
* appropriate operation is skipped.
|
|
||||||
*
|
|
||||||
* sigaddset() adds "sig" to the sigset_t pointed to by "mask".
|
|
||||||
*
|
|
||||||
* sigdelset() removes "sig" from the sigset_t pointed to
|
|
||||||
* by "mask".
|
|
||||||
*
|
|
||||||
* sigemptyset() makes the sigset_t pointed to by "mask" empty.
|
|
||||||
*
|
|
||||||
* sigfillset() makes the sigset_t pointed to by "mask"
|
|
||||||
* full ie. match all signals.
|
|
||||||
*
|
|
||||||
* sigismember() returns true if "sig" is found in "*mask".
|
|
||||||
*
|
|
||||||
* sigpending() is supposed to return "set" loaded with the
|
|
||||||
* set of signals that are blocked and pending for the
|
|
||||||
* calling process. It does nothing in this impementation.
|
|
||||||
*
|
|
||||||
* sigprocmask() is used to examine and/or change the
|
|
||||||
* signal mask for the calling process. Either "set" or
|
|
||||||
* "oset" may be NULL in which case the appropriate
|
|
||||||
* operation is skipped. "how" may be one of SIG_BLOCK,
|
|
||||||
* SIG_UNBLOCK or SIG_SETMASK. If this package is built
|
|
||||||
* with USE_SIGNAL, then this routine achieves nothing.
|
|
||||||
*
|
|
||||||
* sigsuspend() sets the signal mask to "*mask" and waits
|
|
||||||
* for a signal to be delivered after which the previous
|
|
||||||
* mask is restored.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* RETURN VALUE:
|
|
||||||
* 0==success, -1==failure
|
|
||||||
*
|
|
||||||
* BUGS:
|
|
||||||
* Since we fake most of this, don't expect fancy usage to
|
|
||||||
* work.
|
|
||||||
*
|
|
||||||
* AUTHOR:
|
|
||||||
* Simon J. Gerraty <sjg@zen.void.oz.au>
|
|
||||||
*/
|
|
||||||
/* COPYRIGHT:
|
|
||||||
* @(#)Copyright (c) 1992 Simon J. Gerraty
|
|
||||||
*
|
|
||||||
* This is free software. It comes with NO WARRANTY.
|
|
||||||
* Permission to use, modify and distribute this source code
|
|
||||||
* is granted subject to the following conditions.
|
|
||||||
* 1/ that that the above copyright notice and this notice
|
|
||||||
* are preserved in all copies and that due credit be given
|
|
||||||
* to the author.
|
|
||||||
* 2/ that any changes to this code are clearly commented
|
|
||||||
* as such so that the author does get blamed for bugs
|
|
||||||
* other than his own.
|
|
||||||
*
|
|
||||||
* Please send copies of changes and bug-fixes to:
|
|
||||||
* sjg@zen.void.oz.au
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/* Changes to sigact.c for pdksh, Michael Rendell <michael@cs.mun.ca>:
|
|
||||||
* - sigsuspend(): pass *mask to bsd4.2 sigpause instead of mask.
|
|
||||||
* - changed SIG_HDLR to RETSIGTYPE for use with GNU autoconf
|
|
||||||
* - added and used RETSIGVAL
|
|
||||||
* - include sh.h instead of signal.h (to get *_SIGNALS macros)
|
|
||||||
* - changed if !SA_NOCLDSTOP ... to USE_FAKE_SIGACT to avoid confusion
|
|
||||||
* - set the USE_* defines using the *_SIGNALS defines from autoconf
|
|
||||||
* - sigaction(): if using BSD signals, use sigvec() (used to use
|
|
||||||
* signal()) and set the SV_INTERRUPT flag (POSIX says syscalls
|
|
||||||
* are interrupted and pdksh needs this behaviour).
|
|
||||||
* - define IS_KSH before including anything; ifdef out routines
|
|
||||||
* not used in ksh if IS_KSH is defined (same in sigact.h).
|
|
||||||
* - use ARGS() instead of __P()
|
|
||||||
* - sigaction(),sigsuspend(),Signal(),signal(): use handler_t typedef
|
|
||||||
* instead of explicit type.
|
|
||||||
*/
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#ifndef lint
|
|
||||||
__RCSID("$NetBSD: sigact.c,v 1.7 2017/06/23 00:07:15 kamil Exp $");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <signal.h>
|
|
||||||
*/
|
|
||||||
#define IS_KSH
|
|
||||||
#include "sh.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
#ifndef __P
|
|
||||||
# define __P(p) p
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* some systems have a faulty sigaction() implementation!
|
|
||||||
* Allow us to bypass it.
|
|
||||||
* Or they may have installed sigact.h as signal.h which is why
|
|
||||||
* we have SA_NOCLDSTOP defined.
|
|
||||||
*/
|
|
||||||
#ifdef USE_FAKE_SIGACT /* let autoconf decide.. */
|
|
||||||
/* #if !defined(SA_NOCLDSTOP) || defined(_SIGACT_H) || defined(USE_SIGNAL) || defined(USE_SIGSET) || defined(USE_SIGMASK) */
|
|
||||||
|
|
||||||
#define USE_SIGMASK
|
|
||||||
|
|
||||||
#include "sigact.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* in case signal() has been mapped to our Signal().
|
|
||||||
*/
|
|
||||||
#undef signal
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
sigaction(sig, act, oact)
|
|
||||||
int sig;
|
|
||||||
struct sigaction *act, *oact;
|
|
||||||
{
|
|
||||||
handler_t oldh;
|
|
||||||
|
|
||||||
if (act)
|
|
||||||
{
|
|
||||||
#ifdef USE_SIGSET
|
|
||||||
oldh = sigset(sig, act->sa_handler);
|
|
||||||
#else
|
|
||||||
# ifdef USE_SIGMASK
|
|
||||||
struct sigvec nsv,osv;
|
|
||||||
|
|
||||||
nsv.sv_handler = act->sa_handler;
|
|
||||||
nsv.sv_mask = 0; /* punt */
|
|
||||||
nsv.sv_flags = SV_INTERRUPT; /* punt */
|
|
||||||
sigvec(sig, &nsv, &osv);
|
|
||||||
oldh = osv.sv_handler;
|
|
||||||
# else /* USE_SIGMASK */
|
|
||||||
oldh = signal(sig, act->sa_handler);
|
|
||||||
# endif /* USE_SIGMASK */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oact)
|
|
||||||
{
|
|
||||||
#ifdef USE_SIGSET
|
|
||||||
oldh = sigset(sig, SIG_IGN);
|
|
||||||
#else
|
|
||||||
oldh = signal(sig, SIG_IGN);
|
|
||||||
#endif
|
|
||||||
if (oldh != SIG_IGN && oldh != SIG_ERR)
|
|
||||||
{
|
|
||||||
#ifdef USE_SIGSET
|
|
||||||
(void) sigset(sig, oldh);
|
|
||||||
#else
|
|
||||||
(void) signal(sig, oldh);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (oact)
|
|
||||||
{
|
|
||||||
oact->sa_handler = oldh;
|
|
||||||
}
|
|
||||||
return 0; /* hey we're faking it */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
sigaddset(mask, sig)
|
|
||||||
sigset_t *mask;
|
|
||||||
int sig;
|
|
||||||
{
|
|
||||||
*mask |= sigmask(sig);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int
|
|
||||||
sigdelset(mask, sig)
|
|
||||||
sigset_t *mask;
|
|
||||||
int sig;
|
|
||||||
{
|
|
||||||
*mask &= ~(sigmask(sig));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
sigemptyset(mask)
|
|
||||||
sigset_t *mask;
|
|
||||||
{
|
|
||||||
*mask = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int
|
|
||||||
sigfillset(mask)
|
|
||||||
sigset_t *mask;
|
|
||||||
{
|
|
||||||
*mask = ~0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int
|
|
||||||
sigismember(mask, sig)
|
|
||||||
sigset_t *mask;
|
|
||||||
int sig;
|
|
||||||
{
|
|
||||||
return ((*mask) & sigmask(sig));
|
|
||||||
}
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int
|
|
||||||
sigpending(set)
|
|
||||||
sigset_t *set;
|
|
||||||
{
|
|
||||||
return 0; /* faking it! */
|
|
||||||
}
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
sigprocmask(how, set, oset)
|
|
||||||
int how;
|
|
||||||
sigset_t *set, *oset;
|
|
||||||
{
|
|
||||||
#ifdef USE_SIGSET
|
|
||||||
register int i;
|
|
||||||
#endif
|
|
||||||
static sigset_t sm;
|
|
||||||
static int once = 0;
|
|
||||||
|
|
||||||
if (!once)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* initally we clear sm,
|
|
||||||
* there after, it represents the last
|
|
||||||
* thing we did.
|
|
||||||
*/
|
|
||||||
once++;
|
|
||||||
#ifdef USE_SIGMASK
|
|
||||||
sm = sigblock(0);
|
|
||||||
#else
|
|
||||||
sm = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oset)
|
|
||||||
*oset = sm;
|
|
||||||
if (set)
|
|
||||||
{
|
|
||||||
switch (how)
|
|
||||||
{
|
|
||||||
case SIG_BLOCK:
|
|
||||||
sm |= *set;
|
|
||||||
break;
|
|
||||||
case SIG_UNBLOCK:
|
|
||||||
sm &= ~(*set);
|
|
||||||
break;
|
|
||||||
case SIG_SETMASK:
|
|
||||||
sm = *set;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#ifdef USE_SIGMASK
|
|
||||||
(void) sigsetmask(sm);
|
|
||||||
#else
|
|
||||||
# ifdef USE_SIGSET
|
|
||||||
for (i = 1; i < NSIG; i++)
|
|
||||||
{
|
|
||||||
if (how == SIG_UNBLOCK)
|
|
||||||
{
|
|
||||||
if (*set & sigmask(i))
|
|
||||||
sigrelse(i);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (sm & sigmask(i))
|
|
||||||
{
|
|
||||||
sighold(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
sigsuspend(mask)
|
|
||||||
sigset_t *mask;
|
|
||||||
{
|
|
||||||
#ifdef USE_SIGMASK
|
|
||||||
sigpause(*mask);
|
|
||||||
#else
|
|
||||||
register int i;
|
|
||||||
|
|
||||||
# ifdef USE_SIGSET
|
|
||||||
|
|
||||||
for (i = 1; i < NSIG; i++)
|
|
||||||
{
|
|
||||||
if (*mask & sigmask(i))
|
|
||||||
{
|
|
||||||
/* not the same sigpause() as above! */
|
|
||||||
sigpause(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# else /* signal(2) only */
|
|
||||||
handler_t oldh;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* make sure that signals in mask will not
|
|
||||||
* be ignored.
|
|
||||||
*/
|
|
||||||
for (i = 1; i < NSIG; i++)
|
|
||||||
{
|
|
||||||
if (*mask & sigmask(i))
|
|
||||||
{
|
|
||||||
if ((oldh = signal(i, SIG_DFL)) != SIG_ERR &&
|
|
||||||
oldh != SIG_IGN &&
|
|
||||||
oldh != SIG_DFL)
|
|
||||||
(void) signal(i, oldh); /* restore handler */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pause(); /* wait for a signal */
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* USE_FAKE_SIGACT (was ! SA_NOCLDSTOP) */
|
|
||||||
|
|
||||||
#if !defined(RETSIGTYPE)
|
|
||||||
# define RETSIGTYPE void
|
|
||||||
# define RETSIGVAL
|
|
||||||
#endif
|
|
||||||
#if !defined(SIG_ERR)
|
|
||||||
# define SIG_ERR (RETSIGTYPE (*)())-1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* an implementation of signal() using sigaction().
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
handler_t Signal(sig, handler)
|
|
||||||
int sig;
|
|
||||||
handler_t handler;
|
|
||||||
{
|
|
||||||
struct sigaction act, oact;
|
|
||||||
|
|
||||||
act.sa_handler = handler;
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
act.sa_flags = 0;
|
|
||||||
if (sigaction(sig, &act, &oact) < 0)
|
|
||||||
return (SIG_ERR);
|
|
||||||
return (oact.sa_handler);
|
|
||||||
}
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
#if !defined(USE_SIGNAL) && !defined(USE_SIGMASK) && !defined(NO_SIGNAL)
|
|
||||||
/*
|
|
||||||
* ensure we avoid signal mayhem
|
|
||||||
*/
|
|
||||||
|
|
||||||
handler_t signal(sig, handler)
|
|
||||||
int sig;
|
|
||||||
handler_t handler;
|
|
||||||
{
|
|
||||||
return (Signal(sig, handler));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
/* This lot (for GNU-Emacs) goes at the end of the file. */
|
|
||||||
/*
|
|
||||||
* Local Variables:
|
|
||||||
* version-control:t
|
|
||||||
* comment-column:40
|
|
||||||
* End:
|
|
||||||
*/
|
|
125
bin/ksh/sigact.h
125
bin/ksh/sigact.h
|
@ -1,125 +0,0 @@
|
||||||
/* $NetBSD: sigact.h,v 1.3 2002/05/25 23:29:17 wiz Exp $ */
|
|
||||||
|
|
||||||
/* NAME:
|
|
||||||
* sigact.h - sigaction et al
|
|
||||||
*
|
|
||||||
* SYNOPSIS:
|
|
||||||
* #include "sigact.h"
|
|
||||||
*
|
|
||||||
* DESCRIPTION:
|
|
||||||
* This header is the interface to a fake sigaction(2)
|
|
||||||
* implementation. It provides a POSIX compliant interface
|
|
||||||
* to whatever signal handling mechanisms are available.
|
|
||||||
* It also provides a Signal() function that is implemented
|
|
||||||
* in terms of sigaction().
|
|
||||||
* If not using signal(2) as part of the underlying
|
|
||||||
* implementation (USE_SIGNAL or USE_SIGMASK), and
|
|
||||||
* NO_SIGNAL is not defined, it also provides a signal()
|
|
||||||
* function that calls Signal().
|
|
||||||
*
|
|
||||||
* SEE ALSO:
|
|
||||||
* sigact.c
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* RCSid:
|
|
||||||
* $NetBSD: sigact.h,v 1.3 2002/05/25 23:29:17 wiz Exp $
|
|
||||||
*/
|
|
||||||
/* Changes to sigact.h for pdksh, Michael Rendell <michael@cs.mun.ca>:
|
|
||||||
* - changed SIG_HDLR to RETSIGTYPE for use with GNU autoconf
|
|
||||||
* - added RETSIGVAL
|
|
||||||
* - ifdef'd out ARGS(), volatile and const initializations
|
|
||||||
* - ifdef'd out sigset_t definition - let autoconf handle it
|
|
||||||
* - ifdef out routines not used in ksh if IS_KSH is defined
|
|
||||||
* (same in sigact.c).
|
|
||||||
*/
|
|
||||||
#ifndef _SIGACT_H
|
|
||||||
#define _SIGACT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* most modern systems use void for signal handlers but
|
|
||||||
* not all.
|
|
||||||
*/
|
|
||||||
#ifndef RETSIGTYPE
|
|
||||||
# define RETSIGTYPE void
|
|
||||||
# define RETSIGVAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0 /* ARGS(), volatile and const are already set up in config*.h -mhr */
|
|
||||||
#undef ARGS
|
|
||||||
#define ARGS(p) p
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef IS_KSH
|
|
||||||
handler_t Signal ARGS((int sig, handler_t disp));
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if you want to install this header as signal.h,
|
|
||||||
* modify this to pick up the original signal.h
|
|
||||||
*/
|
|
||||||
#ifndef SIGKILL
|
|
||||||
# include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SIG_ERR
|
|
||||||
# define SIG_ERR ((handler_t) -1)
|
|
||||||
#endif
|
|
||||||
#ifndef BADSIG
|
|
||||||
# define BADSIG SIG_ERR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SA_NOCLDSTOP
|
|
||||||
/* we assume we need the fake sigaction */
|
|
||||||
/* sa_flags */
|
|
||||||
#define SA_NOCLDSTOP 1 /* don't send SIGCHLD on child stop */
|
|
||||||
#define SA_RESTART 2 /* re-start I/O */
|
|
||||||
|
|
||||||
/* sigprocmask flags */
|
|
||||||
#define SIG_BLOCK 1
|
|
||||||
#define SIG_UNBLOCK 2
|
|
||||||
#define SIG_SETMASK 4
|
|
||||||
|
|
||||||
#if 0 /* autoconf will define sigset_t if it isn't available */
|
|
||||||
/*
|
|
||||||
* this is a bit untidy
|
|
||||||
*/
|
|
||||||
#if !defined(__sys_stdtypes_h)
|
|
||||||
typedef unsigned int sigset_t;
|
|
||||||
#endif
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* POSIX sa_handler should return void, but since we are
|
|
||||||
* implementing in terms of something else, it may
|
|
||||||
* be appropriate to use the normal RETSIGTYPE return type
|
|
||||||
*/
|
|
||||||
struct sigaction
|
|
||||||
{
|
|
||||||
handler_t sa_handler;
|
|
||||||
sigset_t sa_mask;
|
|
||||||
int sa_flags;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int sigaction ARGS(( int sig, struct sigaction *act, struct sigaction *oact ));
|
|
||||||
int sigaddset ARGS(( sigset_t *mask, int sig ));
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int sigdelset ARGS(( sigset_t *mask, int sig ));
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
int sigemptyset ARGS(( sigset_t *mask ));
|
|
||||||
#ifndef IS_KSH
|
|
||||||
int sigfillset ARGS(( sigset_t *mask ));
|
|
||||||
int sigismember ARGS(( sigset_t *mask, int sig ));
|
|
||||||
int sigpending ARGS(( sigset_t *set ));
|
|
||||||
#endif /* IS_KSH */
|
|
||||||
int sigprocmask ARGS(( int how, sigset_t *set, sigset_t *oset ));
|
|
||||||
int sigsuspend ARGS(( sigset_t *mask ));
|
|
||||||
|
|
||||||
#ifndef sigmask
|
|
||||||
# define sigmask(s) (1<<((s)-1)) /* convert SIGnum to mask */
|
|
||||||
#endif
|
|
||||||
#if !defined(NSIG) && defined(_NSIG)
|
|
||||||
# define NSIG _NSIG
|
|
||||||
#endif
|
|
||||||
#endif /* ! SA_NOCLDSTOP */
|
|
||||||
#endif /* _SIGACT_H */
|
|
Loading…
Reference in New Issue