Mercurial > hg > octave-lyh > gnulib-hg
changeset 15794:13eba3ca057f
raise: Fix double declaration with modules 'sigprocmask' and 'sigpipe'.
* lib/signal.in.h (GNULIB_defined_signal_blocking): New macro.
(raise): Remove older, duplicated declaration.
(_gl_raise_SIGPIPE): New declaration.
* lib/sigprocmask.c (_gl_raise_SIGPIPE): New function.
(rpl_raise): Remove function.
* lib/raise.c (rpl_raise, raise): Merge into a single function. Handle
a gnulib-defined SIGPIPE here.
* m4/raise.m4 (gl_FUNC_RAISE): Set REPLACE_RAISE also if the module
'sigprocmask' has detected missing signal-blocking and the module
'sigpipe' is enabled.
Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 28 Sep 2011 00:49:04 +0200 |
parents | 4e6468fa3ee8 |
children | dd52b68a488b |
files | ChangeLog lib/raise.c lib/signal.in.h lib/sigprocmask.c m4/raise.m4 |
diffstat | 5 files changed, 61 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2011-09-26 Bruno Haible <bruno@clisp.org> + + raise: Fix double declaration with modules 'sigprocmask' and 'sigpipe'. + * lib/signal.in.h (GNULIB_defined_signal_blocking): New macro. + (raise): Remove older, duplicated declaration. + (_gl_raise_SIGPIPE): New declaration. + * lib/sigprocmask.c (_gl_raise_SIGPIPE): New function. + (rpl_raise): Remove function. + * lib/raise.c (rpl_raise, raise): Merge into a single function. Handle + a gnulib-defined SIGPIPE here. + * m4/raise.m4 (gl_FUNC_RAISE): Set REPLACE_RAISE also if the module + 'sigprocmask' has detected missing signal-blocking and the module + 'sigpipe' is enabled. + Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>. + 2011-09-26 Gijs van Tulder <gvtulder@gmail.com> base64-tests: avoid memory leak
--- a/lib/raise.c +++ b/lib/raise.c @@ -50,24 +50,30 @@ return result; } -# define raise raise_nothrow +# else +# define raise_nothrow raise # endif -int -rpl_raise (int sig) -{ - return raise_nothrow (sig); -} - #else /* An old Unix platform. */ # include <unistd.h> -int -raise (int sig) -{ - return kill (getpid (), sig); -} +# define rpl_raise raise #endif + +int +rpl_raise (int sig) +{ +#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE + if (sig == SIGPIPE) + return _gl_raise_SIGPIPE (); +#endif + +#if HAVE_RAISE + return raise_nothrow (sig); +#else + return kill (getpid (), sig); +#endif +}
--- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -178,6 +178,10 @@ #if @GNULIB_SIGPROCMASK@ # if !@HAVE_POSIX_SIGNALBLOCKING@ +# ifndef GNULIB_defined_signal_blocking +# define GNULIB_defined_signal_blocking 1 +# endif + /* Maximum signal number + 1. */ # ifndef NSIG # define NSIG 32 @@ -303,18 +307,10 @@ # endif _GL_CXXALIASWARN (signal); -/* Raise signal SIG. */ # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef raise -# define raise rpl_raise -# endif -_GL_FUNCDECL_RPL (raise, int, (int sig)); -_GL_CXXALIAS_RPL (raise, int, (int sig)); -# else -_GL_CXXALIAS_SYS (raise, int, (int sig)); +/* Raise signal SIGPIPE. */ +_GL_EXTERN_C int _gl_raise_SIGPIPE (void); # endif -_GL_CXXALIASWARN (raise); #elif defined GNULIB_POSIXCHECK # undef sigaddset
--- a/lib/sigprocmask.c +++ b/lib/sigprocmask.c @@ -330,27 +330,19 @@ } #if GNULIB_defined_SIGPIPE -/* Raise the signal SIG. */ +/* Raise the signal SIGPIPE. */ int -rpl_raise (int sig) -# undef raise +_gl_raise_SIGPIPE (void) { - switch (sig) + if (blocked_set & (1U << SIGPIPE)) + pending_array[SIGPIPE] = 1; + else { - case SIGPIPE: - if (blocked_set & (1U << sig)) - pending_array[sig] = 1; - else - { - handler_t handler = SIGPIPE_handler; - if (handler == SIG_DFL) - exit (128 + SIGPIPE); - else if (handler != SIG_IGN) - (*handler) (sig); - } - return 0; - default: /* System defined signal */ - return raise (sig); + handler_t handler = SIGPIPE_handler; + if (handler == SIG_DFL) + exit (128 + SIGPIPE); + else if (handler != SIG_IGN) + (*handler) (SIGPIPE); } } #endif
--- a/m4/raise.m4 +++ b/m4/raise.m4 @@ -1,4 +1,4 @@ -# raise.m4 serial 1 +# raise.m4 serial 2 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,6 +16,17 @@ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then REPLACE_RAISE=1 fi + m4_ifdef([gl_SIGNALBLOCKING], [ + gl_SIGNALBLOCKING + if test $HAVE_POSIX_SIGNALBLOCKING = 0; then + m4_ifdef([gl_SIGNAL_SIGPIPE], [ + gl_SIGNAL_SIGPIPE + if test $gl_cv_header_signal_h_SIGPIPE != yes; then + REPLACE_RAISE=1 + fi + ], [:]) + fi + ]) fi ])