Skip to content

Commit

Permalink
Check if SIGABRT can be trapped multiple times in a row
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Sep 19, 2017
1 parent 8ee67b1 commit 558355e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
])

AX_CHECK_CATCHABLE_SEGV
AX_CHECK_CATCHABLE_ABRT

LT_INIT
AC_SUBST(LIBTOOL_DEPS)
Expand Down
57 changes: 57 additions & 0 deletions m4/ax_check_catchable_abrt.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SYNOPSIS
#
# AX_CHECK_CATCHABLE_ABRT
#
# DESCRIPTION
#
# Check whether SIGABRT can be caught using signal handlers.

#serial 1

AC_DEFUN([AX_CHECK_CATCHABLE_ABRT], [dnl
AC_PREREQ(2.64)
AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_check_[]_AC_LANG_ABBREV[]CATCHABLE_ABRT])dnl
AC_CACHE_CHECK([whether SIGABRT can be caught when using the _AC_LANG compiler], CACHEVAR, [
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
#include <signal.h>
#include <stdlib.h>
#ifndef SIGABRT
# error SIGABRT is not defined
#endif
static void sigabrt_handler_3(int _)
{
exit(0);
}
static void sigabrt_handler_2(int _)
{
signal(SIGABRT, sigabrt_handler_3);
abort();
exit(1);
}
static void sigabrt_handler_1(int _)
{
signal(SIGABRT, sigabrt_handler_2);
abort();
exit(1);
}
]], [[
signal(SIGABRT, sigabrt_handler_1);
abort();
exit(1);
]])],
[AS_VAR_SET(CACHEVAR, [yes])],
[AS_VAR_SET(CACHEVAR, [no])],
[AS_VAR_SET(CACHEVAR, [unknown])]
)
])
AS_VAR_IF(CACHEVAR, yes,
[AC_DEFINE([HAVE_CATCHABLE_ABRT], [1], [Define if SIGABRT can be caught using signal handlers])],
[AC_MSG_WARN([On this platform, SIGABRT cannot be caught using signal handlers.])]
)
AS_VAR_POPDEF([CACHEVAR])dnl
])
2 changes: 1 addition & 1 deletion test/default/misuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TEST_NAME "misuse"
#include "cmptest.h"

#if defined(SIGABRT) && (defined(__APPLE__) || defined(__OpenBSD__))
#ifdef HAVE_CATCHABLE_ABRT
# include <signal.h>

static void
Expand Down

0 comments on commit 558355e

Please sign in to comment.