From: markus schnalke Date: Tue, 27 Mar 2012 06:23:52 +0000 (+0200) Subject: We are making POSIX signal support a requirement. X-Git-Tag: mmh-thesis-end~169 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=ac0b9fcce4167e2959ebc5b8d6efb8511acec66d;p=mmh We are making POSIX signal support a requirement. Remove all support for other signal interfaces. Pulled in from nmh. Thanks to Ken Hornstein. --- diff --git a/configure.ac b/configure.ac index 7b2666c..466a9dd 100644 --- a/configure.ac +++ b/configure.ac @@ -360,9 +360,7 @@ AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, dnl --------------- dnl CHECK FUNCTIONS dnl --------------- -AC_CHECK_FUNCS(sigaction sigprocmask sigblock sigsetmask \ - sighold sigrelse lstat tzset \ - getutent nl_langinfo mbtowc wcwidth) +AC_CHECK_FUNCS(lstat tzset getutent nl_langinfo mbtowc wcwidth) 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 @@ -532,18 +530,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 ---------------- @@ -564,34 +550,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 b8f0865..480bf6d 100644 --- a/h/signals.h +++ b/h/signals.h @@ -10,22 +10,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 1a381db..d1371d0 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -40,7 +40,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"); @@ -49,7 +49,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 11531df..5d0be84 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -579,10 +579,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 15d3f1c..745fa25 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -85,7 +85,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); } @@ -93,7 +93,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 77d61ce..5b55fc4 100644 --- a/sbr/signals.c +++ b/sbr/signals.c @@ -10,46 +10,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; @@ -68,9 +41,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 } @@ -83,7 +53,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) @@ -106,11 +75,4 @@ 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/mhl.c b/uip/mhl.c index e139a83..69797ad 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -1226,10 +1226,6 @@ putch(char ch) static void intrser(int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL(SIGINT, intrser); -#endif - discard(stdout); putchar('\n'); longjmp(env, DONE); @@ -1239,10 +1235,6 @@ intrser(int i) static void pipeser(int i) { -#ifndef RELIABLE_SIGNALS - SIGNAL(SIGPIPE, pipeser); -#endif - done(NOTOK); } @@ -1250,10 +1242,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 374c8fd..6a77d50 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -214,11 +214,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 217e890..ea9f72e 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -136,7 +136,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); @@ -144,7 +144,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(); @@ -665,7 +665,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); } /* @@ -751,7 +751,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; diff --git a/uip/prompter.c b/uip/prompter.c index 2f39f29..6c780d4 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -397,10 +397,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/slocal.c b/uip/slocal.c index 086fac3..9f2e54b 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -1203,10 +1203,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); }