From f475d48680eb8bb0b6543efab9057eba2773666e Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Mon, 9 Jan 2012 13:56:30 -0500 Subject: [PATCH] We are making POSIX signal support a requirement; remove all support for other signal interfaces. --- configure.ac | 45 ++------------------------------------------- h/signals.h | 15 --------------- sbr/context_save.c | 4 ++-- sbr/lock_file.c | 4 ---- sbr/seq_save.c | 4 ++-- sbr/signals.c | 44 +++----------------------------------------- uip/mhlsbr.c | 12 ------------ uip/mhmail.c | 5 ----- uip/mhshowsbr.c | 12 ++++-------- uip/msh.c | 12 ------------ uip/post.c | 4 ---- uip/prompter.c | 4 ---- uip/rcvtty.c | 4 ---- uip/sendsbr.c | 4 ++-- uip/slocal.c | 4 ---- 15 files changed, 15 insertions(+), 162 deletions(-) diff --git a/configure.ac b/configure.ac index db75827..2a56e97 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl -dnl configure.in -- autoconf template for nmh +dnl configure.ac -- autoconf template for nmh dnl dnl Move this up a bit @@ -487,8 +487,7 @@ AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, dnl --------------- dnl CHECK FUNCTIONS dnl --------------- -AC_CHECK_FUNCS(writev lstat tzset getutent nl_langinfo sigaction sigprocmask \ - sigblock sigsetmask sighold sigrelse) +AC_CHECK_FUNCS(writev lstat tzset getutent nl_langinfo) dnl Look for the initgroups() declaration. On AIX 4.[13], Solaris 4.1.3, and dnl ULTRIX 4.2A the function is defined in libc but there's no declaration in @@ -763,18 +762,6 @@ AC_TYPE_UID_T AC_TYPE_MODE_T AC_TYPE_SIZE_T -dnl Check for sigset_t. Currently I'm looking in -dnl and . Others might need -dnl to be added. -AC_CACHE_CHECK(for sigset_t, nmh_cv_type_sigset_t, -[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], [[sigset_t tempsigset;]])], -nmh_cv_type_sigset_t=yes,nmh_cv_type_sigset_t=no)]) -if test $nmh_cv_type_sigset_t = no; then - AC_DEFINE(sigset_t, unsigned int, - [Define to `unsigned int' if or doesn't define.]) -fi - dnl ---------------- dnl CHECK STRUCTURES dnl ---------------- @@ -795,34 +782,6 @@ AC_CHECK_MEMBERS(struct utmp.ut_type,,,[#include ]) AC_STRUCT_DIRENT_D_TYPE -dnl ------------- -dnl CHECK SIGNALS -dnl ------------- -dnl What style of signal do you have (POSIX, BSD, or SYSV)? -AH_TEMPLATE(RELIABLE_SIGNALS, [Define to 1 if you have reliable signals.]) -AC_MSG_CHECKING(what style of signals to use) -if test $ac_cv_func_sigaction = yes -a $ac_cv_func_sigprocmask = yes; then - signals_style=POSIX_SIGNALS - AC_DEFINE(POSIX_SIGNALS, 1, - [Define to 1 if you use POSIX style signal handling.]) - AC_DEFINE(RELIABLE_SIGNALS) -elif test $ac_cv_func_sigblock = yes -a $ac_cv_func_sigsetmask = yes; then - signals_style=BSD_SIGNALS - AC_DEFINE(BSD_SIGNALS,1, - [Define to 1 if you use BSD style signal handling (and can block signals).]) - AC_DEFINE(RELIABLE_SIGNALS) -elif test $ac_cv_func_sighold = yes -a $ac_cv_func_sigrelse = yes; then - signals_style=SYSV_SIGNALS - AC_DEFINE(SYSV_SIGNALS,1, - [Define to 1 if you use SYSV style signal handling (and can block signals).]) -else - signals_style=NO_SIGNAL_BLOCKING - AC_DEFINE(NO_SIGNAL_BLOCKING,1, - [Define to 1 if you have no signal blocking at all (bummer).]) -fi - -AC_MSG_RESULT($signals_style) - dnl Where is located? Needed as input for signames.awk AC_CACHE_CHECK(where signal.h is located, nmh_cv_path_signal_h, [for SIGNAL_H in /usr/include/bsd/sys/signal.h dnl Next diff --git a/h/signals.h b/h/signals.h index 905b811..6f7ed6c 100644 --- a/h/signals.h +++ b/h/signals.h @@ -13,22 +13,7 @@ typedef void (*SIGNAL_HANDLER)(int); /* - * If not a POSIX machine, then we create our - * own POSIX style signal sets functions. This - * currently assumes you have 31 signals, which - * should be true on most pure BSD machines. - */ -#ifndef POSIX_SIGNALS -# define sigemptyset(s) (*(s) = 0) -# define sigfillset(s) (*(s) = ~((sigset_t) 0), 0) -# define sigaddset(s,n) (*(s) |= (1 << ((n) - 1)), 0) -# define sigdelset(s,n) (*(s) &= ~(1 << ((n) - 1)), 0) -# define sigismember(s,n) ((*(s) & (1 << ((n) - 1))) != 0) -#endif - -/* * prototypes */ -int SIGPROCMASK (int, const sigset_t *, sigset_t *); SIGNAL_HANDLER SIGNAL (int, SIGNAL_HANDLER); SIGNAL_HANDLER SIGNAL2 (int, SIGNAL_HANDLER); diff --git a/sbr/context_save.c b/sbr/context_save.c index 4ee40ca..33cd23d 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -41,7 +41,7 @@ context_save (void) sigaddset (&set, SIGINT); sigaddset (&set, SIGQUIT); sigaddset (&set, SIGTERM); - SIGPROCMASK (SIG_BLOCK, &set, &oset); + sigprocmask (SIG_BLOCK, &set, &oset); if (!(out = lkfopen (ctxpath, "w"))) adios (ctxpath, "unable to write"); @@ -50,7 +50,7 @@ context_save (void) fprintf (out, "%s: %s\n", np->n_name, np->n_field); lkfclose (out, ctxpath); - SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset the signal mask */ + sigprocmask (SIG_SETMASK, &oset, &set); /* reset the signal mask */ if (action == 0) _exit (0); /* we are child, time to die */ diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 8f2242a..c4353b5 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -591,10 +591,6 @@ alrmser (int sig) char *lockfile; struct lock *lp; -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGALRM, alrmser); -#endif - /* update the ctime of all the lock files */ for (lp = l_top; lp; lp = lp->l_next) { lockfile = lp->l_lock; diff --git a/sbr/seq_save.c b/sbr/seq_save.c index 94b7543..4055f9d 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -87,7 +87,7 @@ priv: sigaddset(&set, SIGINT); sigaddset(&set, SIGQUIT); sigaddset(&set, SIGTERM); - SIGPROCMASK (SIG_BLOCK, &set, &oset); + sigprocmask (SIG_BLOCK, &set, &oset); } fprintf (fp, "%s: %s\n", mp->msgattrs[i], cp); } @@ -95,7 +95,7 @@ priv: if (fp) { lkfclose (fp, seqfile); - SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset signal mask */ + sigprocmask (SIG_SETMASK, &oset, &set); /* reset signal mask */ } else { /* * If folder is not readonly, and we didn't save any diff --git a/sbr/signals.c b/sbr/signals.c index 919b8e0..eb26e63 100644 --- a/sbr/signals.c +++ b/sbr/signals.c @@ -11,46 +11,19 @@ #include -int -SIGPROCMASK (int how, const sigset_t *set, sigset_t *oset) -{ -#ifdef POSIX_SIGNALS - return sigprocmask(how, set, oset); -#else -# ifdef BSD_SIGNALS - switch(how) { - case SIG_BLOCK: - *oset = sigblock(*set); - break; - case SIG_UNBLOCK: - sigfillset(*oset); - *oset = sigsetmask(*oset); - sigsetmask(*oset & ~(*set)); - break; - case SIG_SETMASK: - *oset = sigsetmask(*set); - break; - default: - adios(NULL, "unknown flag in SIGPROCMASK"); - break; - } - return 0; -# endif -#endif -} - - /* * A version of the function `signal' that uses reliable * signals, if the machine supports them. Also, (assuming * OS support), it restarts interrupted system calls for all * signals except SIGALRM. + * + * Since we are now assuming POSIX signal support everywhere, we always + * use reliable signals. */ SIGNAL_HANDLER SIGNAL (int sig, SIGNAL_HANDLER func) { -#ifdef POSIX_SIGNALS struct sigaction act, oact; act.sa_handler = func; @@ -69,9 +42,6 @@ SIGNAL (int sig, SIGNAL_HANDLER func) if (sigaction(sig, &act, &oact) < 0) return (SIG_ERR); return (oact.sa_handler); -#else - return signal (sig, func); -#endif } @@ -84,7 +54,6 @@ SIGNAL (int sig, SIGNAL_HANDLER func) SIGNAL_HANDLER SIGNAL2 (int sig, SIGNAL_HANDLER func) { -#ifdef POSIX_SIGNALS struct sigaction act, oact; if (sigaction(sig, NULL, &oact) < 0) @@ -107,12 +76,5 @@ SIGNAL2 (int sig, SIGNAL_HANDLER func) return (SIG_ERR); } return (oact.sa_handler); -#else - SIGNAL_HANDLER ofunc; - - if ((ofunc = signal (sig, SIG_IGN)) != SIG_IGN) - signal (sig, func); - return ofunc; -#endif } diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index ed8c477..4cd3770 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -1447,10 +1447,6 @@ putch (char ch) static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGINT, intrser); -#endif - discard (stdout); putchar ('\n'); longjmp (env, DONE); @@ -1460,10 +1456,6 @@ intrser (int i) static void pipeser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGPIPE, pipeser); -#endif - done (NOTOK); } @@ -1471,10 +1463,6 @@ pipeser (int i) static void quitser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGQUIT, quitser); -#endif - putchar ('\n'); fflush (stdout); done (NOTOK); diff --git a/uip/mhmail.c b/uip/mhmail.c index 377fccd..990776c 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -200,11 +200,6 @@ main (int argc, char **argv) static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - if (i) - SIGNAL (i, SIG_IGN); -#endif - unlink (tmpfil); done (i != 0 ? 1 : 0); } diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index c2bb48a..5225825 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -150,7 +150,7 @@ show_single_message (CT ct, char *form) sigaddset (&set, SIGINT); sigaddset (&set, SIGQUIT); sigaddset (&set, SIGTERM); - SIGPROCMASK (SIG_BLOCK, &set, &oset); + sigprocmask (SIG_BLOCK, &set, &oset); while (wait (&status) != NOTOK) { pidcheck (status); @@ -158,7 +158,7 @@ show_single_message (CT ct, char *form) } /* reset the signal mask */ - SIGPROCMASK (SIG_SETMASK, &oset, &set); + sigprocmask (SIG_SETMASK, &oset, &set); xpid = 0; flush_errors (); @@ -710,7 +710,7 @@ show_multi_internal (CT ct, int serial, int alternate) sigaddset (&set, SIGINT); sigaddset (&set, SIGQUIT); sigaddset (&set, SIGTERM); - SIGPROCMASK (SIG_BLOCK, &set, &oset); + sigprocmask (SIG_BLOCK, &set, &oset); } /* @@ -796,7 +796,7 @@ show_multi_internal (CT ct, int serial, int alternate) out: if (!nowserial) { /* reset the signal mask */ - SIGPROCMASK (SIG_SETMASK, &oset, &set); + sigprocmask (SIG_SETMASK, &oset, &set); } return result; @@ -1084,10 +1084,6 @@ show_external (CT ct, int serial, int alternate) static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGINT, intrser); -#endif - putchar ('\n'); siglongjmp (intrenv, DONE); } diff --git a/uip/msh.c b/uip/msh.c index c0fc4e7..07110fd 100644 --- a/uip/msh.c +++ b/uip/msh.c @@ -1621,10 +1621,6 @@ seq_setcur (struct msgs *mp, int msgnum) static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGINT, intrser); -#endif - discard (stdout); interrupted++; @@ -1638,10 +1634,6 @@ intrser (int i) static void pipeser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGPIPE, pipeser); -#endif - if (broken_pipe++ == 0) fprintf (stderr, "broken pipe\n"); told_to_quit++; @@ -1657,10 +1649,6 @@ pipeser (int i) static void quitser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGQUIT, quitser); -#endif - told_to_quit++; interrupted++; diff --git a/uip/post.c b/uip/post.c index 0d71c31..6429cb4 100644 --- a/uip/post.c +++ b/uip/post.c @@ -1614,10 +1614,6 @@ do_text (char *file, int fd) static void sigser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (i, SIG_IGN); -#endif - unlink (tmpfil); if (msgflags & MINV) unlink (bccfil); diff --git a/uip/prompter.c b/uip/prompter.c index 872d742..a016c1f 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -396,10 +396,6 @@ getln (char *buffer, int n) static void intrser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGINT, intrser); -#endif - if (wtuser) longjmp (sigenv, NOTOK); sigint++; diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 6c08dae..5a3093b 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -207,10 +207,6 @@ main (int argc, char **argv) static void alrmser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGALRM, alrmser); -#endif - longjmp (myctx, 1); } diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 110050d..f0c84f5 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -977,14 +977,14 @@ anno (int fd, struct stat *st) sigaddset (&set, SIGINT); sigaddset (&set, SIGQUIT); sigaddset (&set, SIGTERM); - SIGPROCMASK (SIG_BLOCK, &set, &oset); + sigprocmask (SIG_BLOCK, &set, &oset); annoaux (fd); if (child_id == OK) _exit (0); /* reset the signal mask */ - SIGPROCMASK (SIG_SETMASK, &oset, &set); + sigprocmask (SIG_SETMASK, &oset, &set); chdir (cwd); break; diff --git a/uip/slocal.c b/uip/slocal.c index 6b4c306..54960f3 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1214,10 +1214,6 @@ usr_pipe (int fd, char *cmd, char *pgm, char **vec, int suppress) static void alrmser (int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL (SIGALRM, alrmser); -#endif - longjmp (myctx, DONE); } -- 1.7.10.4