From b3f8bee89e3fa5713ff391e0172b8e1d4b92be25 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 12 Dec 2013 22:47:27 -0800 Subject: First cut at signal handling support. * Makefile (OBJS-y): Include signal.o if have_posix_sigs is "y". * configure (have_posix_sigs): New variable, set by detecting POSIX signal stuff. * dep.mk: Regenerated. * arith.c, debug.c, eval.c, filter.c, hash.c, match.c, parser.y, parser.l, rand.c, regex.c, syslog.c, txr.c, utf8.c: Include new signal.h header, now required by unwind, and the system header. * eval.c (exit_wrap): New function. (eval_init): New functions registered as intrinsics: exit_wrap, set_sig_handler, get_sig_handler, sig_check. * gc.c (release): Unused functions removed. * gc.h (release): Declaration removed. * lib.c (init): Call sig_init. * stream.c (set_putc, se_getc, se_fflush): New static functions. (stdio_put_char_callback, stdio_get_char_callback, stdio_put_byte, stdio_flush, stdio_get_byte): Use new functions to enable signals when blocked on I/O. (tail_strategy): Allow signals across sleep. (pipev_close): Allow signals across waitpid. (se_pclose): New static function. (pipe_close): Use new function to enable signals across pclose. * unwind.c (uw_unwind_to_exit_point): use extended_longjmp instead of longjmp. * unwind.h (struct uw_block, struct uw_catch): jb member changes from jmp_buf to extended_jmp_buf. (uw_block_begin, uw_simple_catch_begin, uw_catch_begin): Use extended_setjmp instead of setjmp. * signal.c: New file. * signal.h: New file. --- configure | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 47e88ba9..7ab6931d 100755 --- a/configure +++ b/configure @@ -100,6 +100,7 @@ have_patch= have_unistd= have_timegm= have_syslog= +have_posix_sigs= need_svid_source= need_bsd_source= @@ -576,6 +577,9 @@ tool_prefix := $tool_prefix # do we compile in syslog support? have_syslog := $have_syslog +# do we modern posix signal handling? +have_posix_sigs := $have_posix_sigs + # do we compile in debug support? debug_support := $debug_support @@ -1437,6 +1441,33 @@ else have_syslog=y fi +printf "Checking for reasonably modern POSIX signal handling ... " + +cat > conftest.c < +#include + +int main(void) +{ + sigjmp_buf jb; + static struct sigaction old, new; + static sigset_t olds, news; + sigaction(0, &new, &old); + sigprocmask(SIG_BLOCK, &news, &olds); + if (!sigsetjmp(jb, 1)) + siglongjmp(jb, 1); + return 0; +} +! +rm -f conftest +if ! $make conftest > conftest.err 2>&1 || ! [ -x conftest ] ; then + printf "no\n" +else + printf "yes\n" + printf "#define HAVE_POSIX_SIGS 1\n" >> config.h + have_posix_sigs=y +fi + # # Dependent variables # -- cgit v1.2.3