From: Bruno H. <br...@cl...> - 2008-05-25 09:11:42
|
> 1. unblocks some signal, e.g. SIGINT, using sigprocmask, By the way, all Unix systems nowadays support sigprocmask. (And if they did not, you would find a substitute in gnulib. I may even write a substitute for sigprocmask on mingw some day.) 2008-05-25 Bruno Haible <br...@cl...> * m4/signal.m4 (CL_SIGNALBLOCK): Remove macro. (CL_SIGNAL_UNBLOCK, CL_SIGNAL_BLOCK_OTHERS, CL_SIGACTION_UNBLOCK): Assume POSIX signal-blocking. * unix.d (SIGNALBLOCK_POSIX): Define always. * spvw.d (main): Assume SIGNALBLOCK_POSIX on Unix. * spvw_sigint.d (react_on_sigint): Likewise. * spvw_sigsegv.d (stackoverflow_handler): Likewise. * configure.in (CL_SIGNALBLOCK): Remove invocation. *** configure.in 25 Mar 2008 16:55:32 -0000 1.134 --- configure.in 25 May 2008 09:02:39 -0000 *************** *** 1,5 **** dnl -*- Autoconf -*- configuration for CLISP ! dnl Bruno Haible 1992-2005 dnl Sam Steingold 2002-2008 dnl dnl configure.in ---<autoconf>--->> configure --- 1,5 ---- dnl -*- Autoconf -*- configuration for CLISP ! dnl Bruno Haible 1992-2008 dnl Sam Steingold 2002-2008 dnl dnl configure.in ---<autoconf>--->> configure *************** *** 110,116 **** AC_FUNC_ALLOCA dnl set variable ALLOCA, DEFS NO_ALLOCA CL_SETJMP dnl DEFS HAVE__JMP, LONGJMP_RETURNS CL_TYPE_SIGNAL dnl DEFS RETSIGTYPE, SIGTYPE_DOTS - CL_SIGNALBLOCK dnl DEFS SIGNALBLOCK_POSIX, SIGNALBLOCK_SYSV, SIGNALBLOCK_BSD CL_SIGNAL_REINSTALL dnl DEFS SIGNAL_NEED_REINSTALL CL_SIGNAL_UNBLOCK dnl DEFS SIGNAL_NEED_UNBLOCK CL_SIGNAL_BLOCK_OTHERS dnl DEFS SIGNAL_NEED_UNBLOCK_OTHERS --- 110,115 ---- *** spvw.d 22 Apr 2008 17:31:32 -0000 1.429 --- spvw.d 25 May 2008 09:02:41 -0000 *************** *** 3461,3468 **** sigemptyset(&sigblock_mask); sigaddset(&sigblock_mask,sig); sigprocmask(SIG_UNBLOCK,&sigblock_mask,NULL); } - #elif defined(SIGNALBLOCK_BSD) - sigsetmask(sigblock(0) & ~sigmask(sig)); #endif #endif /* Raise the signal. */ --- 3461,3466 ---- *** spvw_sigint.d 12 Dec 2007 23:13:25 -0000 1.15 --- spvw_sigint.d 25 May 2008 09:02:41 -0000 *************** *** 45,51 **** on our own and hope that it is called by all library- functions (statically linked or via DLL)?? */ ! #if (defined(USE_SIGACTION) ? defined(SIGACTION_NEED_UNBLOCK) : defined(SIGNAL_NEED_UNBLOCK)) || (defined(GNU_READLINE) && (defined(SIGNALBLOCK_BSD) || defined(SIGNALBLOCK_POSIX))) /* either if handlers, installed with [SIGNAL_NEED_UNBLOCK] and signal(), are called with blocked signal anyway - usually on BSD-systems -, or if other unsecure components [GNU_READLINE] can cause --- 45,51 ---- on our own and hope that it is called by all library- functions (statically linked or via DLL)?? */ ! #if (defined(USE_SIGACTION) ? defined(SIGACTION_NEED_UNBLOCK) : defined(SIGNAL_NEED_UNBLOCK)) || (defined(GNU_READLINE) && defined(SIGNALBLOCK_POSIX)) /* either if handlers, installed with [SIGNAL_NEED_UNBLOCK] and signal(), are called with blocked signal anyway - usually on BSD-systems -, or if other unsecure components [GNU_READLINE] can cause *************** *** 57,64 **** sigemptyset(&sigblock_mask); sigaddset(&sigblock_mask,sig); sigprocmask(SIG_UNBLOCK,&sigblock_mask,NULL); } - #elif defined(SIGNALBLOCK_BSD) - sigsetmask(sigblock(0) & ~sigmask(sig)); #endif #endif #ifdef HAVE_SAVED_STACK --- 57,62 ---- *** spvw_sigsegv.d 12 Dec 2007 23:13:25 -0000 1.25 --- spvw_sigsegv.d 25 May 2008 09:02:41 -0000 *************** *** 80,86 **** #ifdef UNIX /* Unblock signals blocked by libsigsegv/src/handler-unix.c:install_for() Alternatively unblock all signals */ - #if defined(SIGNALBLOCK_POSIX) { var sigset_t sigblock_mask; /* sigemptyset(&sigblock_mask); sigaddset(&sigblock_mask,SIGSEGV); --- 80,85 ---- *************** *** 91,99 **** sigfillset(&sigblock_mask); sigprocmask(SIG_UNBLOCK,&sigblock_mask,NULL); } - #elif defined(SIGNALBLOCK_BSD) - sigsetmask(0); - #endif #endif sigsegv_leave_handler(); #ifdef HAVE_SAVED_STACK --- 90,95 ---- *** unix.d 22 Apr 2008 17:31:33 -0000 1.80 --- unix.d 25 May 2008 09:02:41 -0000 *************** *** 1,6 **** /* * The include file for the UNIX version of CLISP ! * Bruno Haible 1990-2007 * Sam Steingold 1998-2007 */ --- 1,6 ---- /* * The include file for the UNIX version of CLISP ! * Bruno Haible 1990-2008 * Sam Steingold 1998-2007 */ *************** *** 233,266 **** #endif extern signal_handler_t install_signal_handler (int sig, signal_handler_t handler); #define SIGNAL(sig,handler) install_signal_handler(sig,handler) ! /* a signal block and release: */ ! #if defined(SIGNALBLOCK_POSIX) ! /* extern_C int sigprocmask (int how, const sigset_t* set, sigset_t* oset); */ /* SIGPROCMASK(2V) */ ! /* extern_C int sigemptyset (sigset_t* set); */ /* SIGSETOPS(3V) */ ! /* extern_C int sigaddset (sigset_t* set, int signo); */ /* SIGSETOPS(3V) */ ! #define signalblock_on(sig) \ ! { var sigset_t sigblock_mask; \ ! sigemptyset(&sigblock_mask); sigaddset(&sigblock_mask,sig); \ ! sigprocmask(SIG_BLOCK,&sigblock_mask,NULL); ! #define signalblock_off(sig) \ ! sigprocmask(SIG_UNBLOCK,&sigblock_mask,NULL); \ ! } ! #elif defined(SIGNALBLOCK_SYSV) ! extern_C int sighold (int sig); ! extern_C int sigrelse (int sig); ! #define signalblock_on(sig) sighold(sig); ! #define signalblock_off(sig) sigrelse(sig); ! #elif defined(SIGNALBLOCK_BSD) ! extern_C int sigblock (int mask); /* SIGBLOCK(2) */ ! extern_C int sigsetmask (int mask); /* SIGSETMASK(2) */ ! #define signalblock_on(sig) \ ! { var int old_sigblock_mask = sigblock(sigmask(sig)); ! #define signalblock_off(sig) \ ! sigsetmask(old_sigblock_mask); \ ! } ! #else ! #error How does one block a signal? ! #endif /* deliver a signal some time later: */ /* extern_C {unsigned|} int alarm ({unsigned|} int seconds); / * ALARM(3V) */ #if !defined(HAVE_UALARM) && defined(HAVE_SETITIMER) --- 233,250 ---- #endif extern signal_handler_t install_signal_handler (int sig, signal_handler_t handler); #define SIGNAL(sig,handler) install_signal_handler(sig,handler) ! /* Block and unblock (= delay and reenable) a signal: */ ! #define SIGNALBLOCK_POSIX /* all Unix systems support the POSIX API for signal blocking */ ! /* extern_C int sigprocmask (int how, const sigset_t* set, sigset_t* oset); */ /* SIGPROCMASK(2V) */ ! /* extern_C int sigemptyset (sigset_t* set); */ /* SIGSETOPS(3V) */ ! /* extern_C int sigaddset (sigset_t* set, int signo); */ /* SIGSETOPS(3V) */ ! #define signalblock_on(sig) \ ! { var sigset_t sigblock_mask; \ ! sigemptyset(&sigblock_mask); sigaddset(&sigblock_mask,sig); \ ! sigprocmask(SIG_BLOCK,&sigblock_mask,NULL); ! #define signalblock_off(sig) \ ! sigprocmask(SIG_UNBLOCK,&sigblock_mask,NULL); \ ! } /* deliver a signal some time later: */ /* extern_C {unsigned|} int alarm ({unsigned|} int seconds); / * ALARM(3V) */ #if !defined(HAVE_UALARM) && defined(HAVE_SETITIMER) *** m4/signal.m4 2 Oct 2003 09:40:39 -0000 1.5 --- m4/signal.m4 25 May 2008 09:02:42 -0000 *************** *** 1,5 **** dnl -*- Autoconf -*- ! dnl Copyright (C) 1993-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program --- 1,5 ---- dnl -*- Autoconf -*- ! dnl Copyright (C) 1993-2008 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program *************** *** 81,108 **** fi ]) - AC_DEFUN([CL_SIGNALBLOCK], - [AC_BEFORE([$0], [CL_SIGNAL_UNBLOCK])dnl - AC_BEFORE([$0], [CL_SIGNAL_BLOCK_OTHERS])dnl - signalblocks="" - AC_CHECK_FUNC(sighold, AC_DEFINE(SIGNALBLOCK_SYSV,,[how to block and unblock signals]) - signalblocks="$signalblocks SystemV", )dnl - AC_EGREP_HEADER(sigset_t, signal.h, , signals_not_posix=1)dnl - if test -z "$signals_not_posix"; then - AC_CHECK_FUNC(sigprocmask, AC_DEFINE(SIGNALBLOCK_POSIX,,[how to block and unblock signals]) - signalblocks="$signalblocks POSIX", )dnl - fi - AC_CHECK_FUNC(sigblock, AC_DEFINE(SIGNALBLOCK_BSD,,[how to block and unblock signals]) - signalblocks="$signalblocks BSD", )dnl - AC_CACHE_CHECK(for signal blocking interfaces, cl_cv_func_signalblocks, [ - if test -z "$signalblocks"; then - cl_cv_func_signalblocks="none" - else - cl_cv_func_signalblocks=`echo $signalblocks` - fi - ]) - ]) - AC_DEFUN([CL_SIGNAL_REINSTALL], [AC_BEFORE([$0], [CL_SIGNAL_UNBLOCK])dnl AC_BEFORE([$0], [CL_SIGNAL_BLOCK_OTHERS])dnl --- 81,86 ---- *************** *** 149,155 **** ]) AC_DEFUN([CL_SIGNAL_UNBLOCK], ! [AC_REQUIRE([CL_SIGNAL_REINSTALL])AC_REQUIRE([CL_SIGNALBLOCK])dnl case "$signalblocks" in *POSIX* | *BSD*) AC_CACHE_CHECK(whether signals are blocked when signal handlers are entered, cl_cv_func_signal_blocked, [ --- 127,133 ---- ]) AC_DEFUN([CL_SIGNAL_UNBLOCK], ! [AC_REQUIRE([CL_SIGNAL_REINSTALL])dnl case "$signalblocks" in *POSIX* | *BSD*) AC_CACHE_CHECK(whether signals are blocked when signal handlers are entered, cl_cv_func_signal_blocked, [ *************** *** 183,196 **** #ifdef SIGNAL_NEED_REINSTALL signal(SIGALRM,(signal_handler_t)sigalrm_handler); #endif - #ifdef SIGNALBLOCK_POSIX { sigset_t blocked; sigprocmask(SIG_BLOCK, (sigset_t *) 0, &blocked); wasblocked = sigismember(&blocked,SIGALRM) ? 1 : 0; } - #else - wasblocked = ((sigblock(0) & sigmask(SIGALRM)) != 0); - #endif } int got_sig () { return gotsig; } int main() { /* returns 0 if they need not to be unblocked */ --- 161,170 ---- *************** *** 210,216 **** ]) AC_DEFUN([CL_SIGNAL_BLOCK_OTHERS], ! [AC_REQUIRE([CL_SIGNAL_REINSTALL])AC_REQUIRE([CL_SIGNALBLOCK])dnl case "$signalblocks" in *POSIX* | *BSD*) AC_CACHE_CHECK(whether other signals are blocked when signal handlers are entered, cl_cv_func_signal_blocked_others, [ --- 184,190 ---- ]) AC_DEFUN([CL_SIGNAL_BLOCK_OTHERS], ! [AC_REQUIRE([CL_SIGNAL_REINSTALL])dnl case "$signalblocks" in *POSIX* | *BSD*) AC_CACHE_CHECK(whether other signals are blocked when signal handlers are entered, cl_cv_func_signal_blocked_others, [ *************** *** 244,250 **** #ifdef SIGNAL_NEED_REINSTALL signal(SIGALRM,(signal_handler_t)sigalrm_handler); #endif - #ifdef SIGNALBLOCK_POSIX { sigset_t blocked; int i; sigprocmask(SIG_BLOCK, (sigset_t *) 0, &blocked); --- 218,223 ---- *************** *** 252,260 **** if (i!=SIGALRM && sigismember(&blocked,i)) somewereblocked = 1; } - #else - somewereblocked = ((sigblock(0) & ~sigmask(SIGALRM)) != 0); - #endif } int got_sig () { return gotsig; } int main() { /* returns 0 if they need not to be unblocked */ --- 225,230 ---- *************** *** 345,351 **** [AC_REQUIRE([CL_TYPE_SIGNAL])dnl AC_REQUIRE([CL_SIGACTION])dnl AC_REQUIRE([CL_SIGACTION_REINSTALL])dnl - AC_REQUIRE([CL_SIGNALBLOCK])dnl if test -n "$have_sigaction"; then case "$signalblocks" in *POSIX* | *BSD*) --- 315,320 ---- *************** *** 394,407 **** #ifdef SIGNAL_NEED_REINSTALL mysignal(SIGALRM,(signal_handler_t)sigalrm_handler); #endif - #ifdef SIGNALBLOCK_POSIX { sigset_t blocked; sigprocmask(SIG_BLOCK, (sigset_t *) 0, &blocked); wasblocked = sigismember(&blocked,SIGALRM) ? 1 : 0; } - #else - wasblocked = ((sigblock(0) & sigmask(SIGALRM)) != 0); - #endif } int got_sig () { return gotsig; } int main() { /* returns 0 if they need not to be unblocked */ --- 363,372 ---- |