Skip to content

Commit

Permalink
check for sigaction via configure; assume signal always available
Browse files Browse the repository at this point in the history
  • Loading branch information
svigerske committed Dec 13, 2024
1 parent 1760fc9 commit 5ba4f3e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
16 changes: 15 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <csignal>
" "$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 #
###################################################
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ AC_CHECK_DECL([feenableexcept],
[AC_DEFINE([IPOPT_HAS_FEENABLEEXCEPT],[1],[Define to 1 if function feenableexcept is available])],,
[#include <cfenv>])

#############
# 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 <csignal>])

###################################################
# Check if user wants inexact algorithm available #
###################################################
Expand Down
12 changes: 4 additions & 8 deletions src/Common/IpUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Common/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5ba4f3e

Please sign in to comment.