Remove sigaction emulation
Use SA_INTERRUPT in sa_flags
This commit is contained in:
@@ -1,123 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001-2005 Todd C. Miller <Todd.Miller@courtesan.com>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*
|
|
||||||
* Sponsored in part by the Defense Advanced Research Projects
|
|
||||||
* Agency (DARPA) and Air Force Research Laboratory, Air Force
|
|
||||||
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <compat.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
sigaction(int signo, const sigaction_t *sa, sigaction_t *osa)
|
|
||||||
{
|
|
||||||
sigaction_t nsa;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/* We must reverse SV_INTERRUPT since it is the opposite of SA_RESTART */
|
|
||||||
if (sa) {
|
|
||||||
nsa = *sa;
|
|
||||||
nsa.sa_flags ^= SV_INTERRUPT;
|
|
||||||
sa = &nsa;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = sigvec(signo, sa, osa);
|
|
||||||
if (!error && osa)
|
|
||||||
osa->sa_flags ^= SV_INTERRUPT; /* flip SV_INTERRUPT as above */
|
|
||||||
|
|
||||||
return(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigemptyset(sigset_t *set)
|
|
||||||
{
|
|
||||||
|
|
||||||
*set = 0;
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigfillset(sigset_t *set)
|
|
||||||
{
|
|
||||||
|
|
||||||
*set = ~0;;
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigaddset(sigset_t *set, int signo)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (signo <= 0 || signo >= NSIG) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SET(*set, sigmask(signo));
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigdelset(sigset_t *set, int signo)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (signo <= 0 || signo >= NSIG) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
CLR(*set, sigmask(signo));
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigismember(sigset_t *set, int signo)
|
|
||||||
{
|
|
||||||
|
|
||||||
return(ISSET(*set, sigmask(signo)));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
sigprocmask(int how, const sigset_t *set, sigset_t *oset)
|
|
||||||
{
|
|
||||||
int mask;
|
|
||||||
|
|
||||||
/* If 'set' is NULL the user just wants the current signal mask. */
|
|
||||||
if (set == 0)
|
|
||||||
mask = sigblock(0);
|
|
||||||
else
|
|
||||||
switch (how) {
|
|
||||||
case SIG_BLOCK:
|
|
||||||
mask = sigblock(*set);
|
|
||||||
break;
|
|
||||||
case SIG_UNBLOCK:
|
|
||||||
mask = sigsetmask(~*set);
|
|
||||||
break;
|
|
||||||
case SIG_SETMASK:
|
|
||||||
mask = sigsetmask(*set);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mask == -1)
|
|
||||||
return(-1);
|
|
||||||
if (oset)
|
|
||||||
*oset = mask;
|
|
||||||
return(0);
|
|
||||||
}
|
|
@@ -433,9 +433,6 @@
|
|||||||
/* Define to 1 if you have the `sia_ses_init' function. */
|
/* Define to 1 if you have the `sia_ses_init' function. */
|
||||||
#undef HAVE_SIA_SES_INIT
|
#undef HAVE_SIA_SES_INIT
|
||||||
|
|
||||||
/* Define to 1 if you have the `sigaction' function. */
|
|
||||||
#undef HAVE_SIGACTION
|
|
||||||
|
|
||||||
/* Define to 1 if <signal.h> has the sigaction_t typedef. */
|
/* Define to 1 if <signal.h> has the sigaction_t typedef. */
|
||||||
#undef HAVE_SIGACTION_T
|
#undef HAVE_SIGACTION_T
|
||||||
|
|
||||||
|
@@ -1957,7 +1957,7 @@ AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_F
|
|||||||
AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)])
|
AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)])
|
||||||
SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)])
|
SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)])
|
||||||
SUDO_FUNC_ISBLANK
|
SUDO_FUNC_ISBLANK
|
||||||
AC_REPLACE_FUNCS(memrchr strerror strcasecmp sigaction strlcpy strlcat)
|
AC_REPLACE_FUNCS(memrchr strerror strcasecmp strlcpy strlcat)
|
||||||
AC_CHECK_FUNCS(nanosleep, [], [
|
AC_CHECK_FUNCS(nanosleep, [], [
|
||||||
# On Solaris, nanosleep is in librt
|
# On Solaris, nanosleep is in librt
|
||||||
AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)])
|
AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)])
|
||||||
|
@@ -181,41 +181,17 @@ int isblank(int);
|
|||||||
#endif /* O_NOCTTY */
|
#endif /* O_NOCTTY */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Emulate POSIX signals via sigvec(2)
|
* Add IRIX-like sigaction_t for those without it.
|
||||||
|
* SA_RESTART is not required by POSIX; SunOS has SA_INTERRUPT instead.
|
||||||
*/
|
*/
|
||||||
#ifndef HAVE_SIGACTION
|
#ifndef HAVE_SIGACTION_T
|
||||||
# define SA_ONSTACK SV_ONSTACK
|
|
||||||
# define SA_RESTART SV_INTERRUPT /* opposite effect */
|
|
||||||
# define SA_RESETHAND SV_RESETHAND
|
|
||||||
# define SA_NOCLDSTOP SV_NOCLDSTOP
|
|
||||||
# define sa_handler sv_handler
|
|
||||||
# define sa_mask sv_mask
|
|
||||||
# define sa_flags sv_flags
|
|
||||||
typedef struct sigvec sigaction_t;
|
|
||||||
typedef int sigset_t;
|
|
||||||
int sigaction(int sig, const sigaction_t *act, sigaction_t *oact);
|
|
||||||
int sigemptyset(sigset_t *);
|
|
||||||
int sigfillset(sigset_t *);
|
|
||||||
int sigaddset(sigset_t *, int);
|
|
||||||
int sigdelset(sigset_t *, int);
|
|
||||||
int sigismember(sigset_t *, int);
|
|
||||||
int sigprocmask(int, const sigset_t *, sigset_t *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extra sugar for POSIX signals to deal with the above emulation
|
|
||||||
* as well as the fact that SunOS has a SA_INTERRUPT flag.
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_SIGACTION
|
|
||||||
# ifndef HAVE_SIGACTION_T
|
|
||||||
typedef struct sigaction sigaction_t;
|
typedef struct sigaction sigaction_t;
|
||||||
# endif
|
#endif
|
||||||
# ifndef SA_INTERRUPT
|
#ifndef SA_INTERRUPT
|
||||||
# define SA_INTERRUPT 0
|
# define SA_INTERRUPT 0
|
||||||
# endif
|
#endif
|
||||||
# ifndef SA_RESTART
|
#ifndef SA_RESTART
|
||||||
# define SA_RESTART 0
|
# define SA_RESTART 0
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -478,7 +478,7 @@ send_mail(const char *fmt, ...)
|
|||||||
/* Ignore SIGPIPE in case mailer exits prematurely (or is missing). */
|
/* Ignore SIGPIPE in case mailer exits prematurely (or is missing). */
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_INTERRUPT;
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
(void) sigaction(SIGPIPE, &sa, NULL);
|
(void) sigaction(SIGPIPE, &sa, NULL);
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@ systrace_attach(pid)
|
|||||||
error(1, "sigprocmask");
|
error(1, "sigprocmask");
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_INTERRUPT;
|
||||||
sa.sa_handler = catchsig;
|
sa.sa_handler = catchsig;
|
||||||
if (sigaction(SIGUSR1, &sa, &osa) != 0)
|
if (sigaction(SIGUSR1, &sa, &osa) != 0)
|
||||||
error(1, "sigaction");
|
error(1, "sigaction");
|
||||||
@@ -151,7 +151,7 @@ systrace_attach(pid)
|
|||||||
dodetach = 0;
|
dodetach = 0;
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_INTERRUPT;
|
||||||
sa.sa_handler = catchsig;
|
sa.sa_handler = catchsig;
|
||||||
if (sigaction(SIGUSR1, &osa, NULL) != 0 ||
|
if (sigaction(SIGUSR1, &osa, NULL) != 0 ||
|
||||||
sigaction(SIGHUP, &sa, NULL) != 0 ||
|
sigaction(SIGHUP, &sa, NULL) != 0 ||
|
||||||
|
@@ -176,7 +176,7 @@ sudo_execve(struct command_details *details, char *argv[], char *envp[],
|
|||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
|
||||||
/* Note: HP-UX select() will not be interrupted if SA_RESTART set */
|
/* Note: HP-UX select() will not be interrupted if SA_RESTART set */
|
||||||
sa.sa_flags = 0; /* do not restart syscalls */
|
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
||||||
sa.sa_handler = handler;
|
sa.sa_handler = handler;
|
||||||
sigaction(SIGALRM, &sa, NULL);
|
sigaction(SIGALRM, &sa, NULL);
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
sigaction(SIGCHLD, &sa, NULL);
|
||||||
|
@@ -532,7 +532,7 @@ fork_pty(struct command_details *details, char *argv[], char *envp[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Job control signals to relay from parent to child. */
|
/* Job control signals to relay from parent to child. */
|
||||||
sa.sa_flags = 0; /* do not restart syscalls */
|
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
||||||
sa.sa_handler = handler;
|
sa.sa_handler = handler;
|
||||||
sigaction(SIGTSTP, &sa, NULL);
|
sigaction(SIGTSTP, &sa, NULL);
|
||||||
#if 0 /* XXX - add these? */
|
#if 0 /* XXX - add these? */
|
||||||
@@ -823,7 +823,7 @@ exec_monitor(struct command_details *details, char *argv[], char *envp[],
|
|||||||
sigaction(SIGTTOU, &sa, NULL);
|
sigaction(SIGTTOU, &sa, NULL);
|
||||||
|
|
||||||
/* Note: HP-UX select() will not be interrupted if SA_RESTART set */
|
/* Note: HP-UX select() will not be interrupted if SA_RESTART set */
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_INTERRUPT;
|
||||||
sa.sa_handler = handler;
|
sa.sa_handler = handler;
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
sigaction(SIGCHLD, &sa, NULL);
|
||||||
|
|
||||||
|
@@ -241,7 +241,7 @@ sudo_askpass(const char *askpass, const char *prompt)
|
|||||||
/* Ignore SIGPIPE in case child exits prematurely */
|
/* Ignore SIGPIPE in case child exits prematurely */
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_INTERRUPT;
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
(void) sigaction(SIGPIPE, &sa, &saved_sa_pipe);
|
(void) sigaction(SIGPIPE, &sa, &saved_sa_pipe);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user