diff --git a/configure b/configure index 214b72647..48e8fbb8f 100755 --- a/configure +++ b/configure @@ -28217,6 +28217,20 @@ printf "%s\n" "#define IPOPT_HAS_FEENABLEEXCEPT 1" >>confdefs.h fi +############# +# sigaction # +############# + +as_ac_Symbol=`printf "%s\n" "ac_cv_have_decl_sigaction(int, const struct sigaction*, struct sigaction*)" | sed "$as_sed_sh"` +ac_fn_check_decl "$LINENO" "sigaction(int, const struct sigaction*, struct sigaction*)" "$as_ac_Symbol" "#include +" "$ac_cxx_undeclared_builtin_options" "CXXFLAGS" +if eval test \"x\$"$as_ac_Symbol"\" = x"yes" +then : + +printf "%s\n" "#define IPOPT_HAS_SIGACTION 1" >>confdefs.h + +fi + ################################################### # Check if user wants inexact algorithm available # ################################################### @@ -28398,7 +28412,7 @@ else case e in #( JAVA_TEST=Test.java CLASS_TEST=Test.class cat << \EOF > $JAVA_TEST -/* #line 28401 "configure" */ +/* #line 28415 "configure" */ public class Test { } EOF diff --git a/configure.ac b/configure.ac index 4b7c5e168..50d9b1447 100644 --- a/configure.ac +++ b/configure.ac @@ -336,6 +336,14 @@ AC_CHECK_DECL([feenableexcept], [AC_DEFINE([IPOPT_HAS_FEENABLEEXCEPT],[1],[Define to 1 if function feenableexcept is available])],, [#include ]) +############# +# sigaction # +############# + +AC_CHECK_DECL([sigaction(int, const struct sigaction*, struct sigaction*)], + [AC_DEFINE([IPOPT_HAS_SIGACTION],[1],[Define to 1 if function sigaction is available])],, + [#include ]) + ################################################### # Check if user wants inexact algorithm available # ################################################### diff --git a/src/Common/IpUtils.cpp b/src/Common/IpUtils.cpp index 5052a4579..204957c9a 100644 --- a/src/Common/IpUtils.cpp +++ b/src/Common/IpUtils.cpp @@ -231,7 +231,7 @@ bool RegisterInterruptHandler( handle_interrupt_ = handle_interrupt; interrupt_flag_ = interrupt_flag; -#ifdef _POSIX_C_SOURCE +#ifdef IPOPT_HAS_SIGACTION struct sigaction sa; sa.sa_handler = &sighandler; sa.sa_flags = SA_RESTART; @@ -245,13 +245,11 @@ bool RegisterInterruptHandler( return false; } -#elif defined(_WIN32) +#else signal(SIGINT, sighandler); signal(SIGTERM, sighandler); signal(SIGABRT, sighandler); -#else - return false; #endif return true; @@ -264,7 +262,7 @@ bool UnregisterInterruptHandler(void) return false; } -#ifdef _POSIX_C_SOURCE +#ifdef IPOPT_HAS_SIGACTION struct sigaction sa; sa.sa_handler = SIG_DFL; sa.sa_flags = SA_RESTART; @@ -278,13 +276,11 @@ bool UnregisterInterruptHandler(void) return false; } -#elif defined(_WIN32) +#else signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGABRT, SIG_DFL); -#else - return false; #endif registered_handler = false; diff --git a/src/Common/config.h.in b/src/Common/config.h.in index dd89b89f7..5d8438eae 100644 --- a/src/Common/config.h.in +++ b/src/Common/config.h.in @@ -126,6 +126,9 @@ /* Define to 1 if function rand is available */ #undef IPOPT_HAS_RAND +/* Define to 1 if function sigaction is available */ +#undef IPOPT_HAS_SIGACTION + /* Define to 1 if the Spral package is available */ #undef IPOPT_HAS_SPRAL