From 1795be71fb9db24aaa5d3ef2fd71f0f952ccb72f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 14 Nov 2006 20:22:12 +0000 Subject: [PATCH] Don't assume SIGPIPE exists, and that sigblock and sigsetmask exist if sigprocmask does not. Problem reported by Paul Edwards for MVS 3.8. * configure.ac (sigblock): Check whether this function is available, if sigprocmask is not. * src/sdiff.c (sigs): Omit SIGPIPE if it's not defined. Put SIGINT last; all uses changed. (handler_index_of_SIGPIPE): Omit if SIGPIPE is not defined. (sigblock, sigsetmask) [!HAVE_SIGBLOCK]: New macros. --- ChangeLog | 12 ++++++++++++ configure.ac | 3 +++ src/sdiff.c | 14 ++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4347dcb..bea73f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-11-14 Paul Eggert + + Don't assume SIGPIPE exists, and that sigblock and sigsetmask + exist if sigprocmask does not. Problem reported by Paul Edwards + for MVS 3.8. + * configure.ac (sigblock): Check whether this function is + available, if sigprocmask is not. + * src/sdiff.c (sigs): Omit SIGPIPE if it's not defined. + Put SIGINT last; all uses changed. + (handler_index_of_SIGPIPE): Omit if SIGPIPE is not defined. + (sigblock, sigsetmask) [!HAVE_SIGBLOCK]: New macros. + 2006-11-04 Paul Eggert * src/sdiff.c (sigprocmask) [! HAVE_SIGPROCMASK]: Cast 2nd arg to diff --git a/configure.ac b/configure.ac index d5769df..1da2748 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,9 @@ AC_HEADER_SYS_WAIT AC_TYPE_PID_T AC_CHECK_FUNCS_ONCE([sigaction sigprocmask strcasecoll stricoll]) +if test $ac_cv_func_sigprocmask = no; then + AC_CHECK_FUNCS([sigblock]) +fi AC_FUNC_CLOSEDIR_VOID AC_FUNC_FORK diff --git a/src/sdiff.c b/src/sdiff.c index 8f53762..ab57e39 100644 --- a/src/sdiff.c +++ b/src/sdiff.c @@ -81,11 +81,13 @@ static int const sigs[] = { #ifdef SIGXFSZ SIGXFSZ, #endif - SIGINT, - SIGPIPE +#ifdef SIGPIPE + SIGPIPE, +# define handler_index_of_SIGPIPE (NUM_SIGS - 2) +#endif + SIGINT +#define handler_index_of_SIGINT (NUM_SIGS - 1) }; -#define handler_index_of_SIGINT (NUM_SIGS - 2) -#define handler_index_of_SIGPIPE (NUM_SIGS - 1) #if HAVE_SIGACTION /* Prefer `sigaction' if available, since `signal' can lose signals. */ @@ -111,6 +113,10 @@ static int const sigs[] = { # ifndef SIG_SETMASK # define SIG_SETMASK (! SIG_BLOCK) # endif +# if ! HAVE_SIGBLOCK +# define sigblock(mask) (mask) +# define sigsetmask(mask) (mask) +# endif # define sigprocmask(how, n, o) \ ((how) == SIG_BLOCK \ ? *(sigset_t *) (o) = sigblock (*(n)) \