From f40925f67b4310837957a096ca07e3f5522e7f95 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 14 Oct 2012 12:49:26 +0200 Subject: [PATCH] ltlcheck: disable timeout handling when kill() or alarm() are missing * configure.ac: Check for kill and alarm. * src/bin/ltlcheck.cc: Disable timeout code when kill or alarm are missing. Recognize the --timeout option, but display a warning. --- configure.ac | 2 +- src/bin/ltlcheck.cc | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 0d033dd27..811c12038 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ AX_CHECK_GSPNLIB AX_CHECK_BOOST([1.34], [103400]) AC_CHECK_HEADERS([sys/times.h]) -AC_CHECK_FUNCS([times srand48 drand48]) +AC_CHECK_FUNCS([times srand48 drand48 kill alarm]) LT_CONFIG_LTDL_DIR([ltdl]) LT_INIT([win32-dll]) diff --git a/src/bin/ltlcheck.cc b/src/bin/ltlcheck.cc index a8e628ccf..a5aba3fca 100644 --- a/src/bin/ltlcheck.cc +++ b/src/bin/ltlcheck.cc @@ -51,6 +51,14 @@ #include "tgbaalgos/stats.hh" #include "tgbaalgos/isdet.hh" +// Disable handling of timeout on systems that miss kill() or alarm(). +// For instance MinGW. +#if HAVE_KILL && HAVE_ALARM +# define ENABLE_TIMEOUT 1 +#else +# define ENABLE_TIMEOUT 0 +#endif + const char argp_program_doc[] ="\ Call several LTL/PSL translators and cross-compare their output to detect \ bugs, or to gather statistics. The list of formulas to use should be \ @@ -226,6 +234,10 @@ parse_opt(int key, char* arg, struct argp_state*) break; case 'T': timeout = to_pos_int(arg); +#if !ENABLE_TIMEOUT + std::cerr << "warning: setting a timeout is not supported " + << "on your platform" << std::endl; +#endif break; case OPT_DENSITY: density = to_probability(arg); @@ -252,8 +264,9 @@ create_tmpfile(char c, unsigned int n, std::string& name) } -static volatile int alarm_on = 0; static volatile bool timed_out = false; +#if ENABLE_TIMEOUT +static volatile int alarm_on = 0; static int child_pid = -1; static volatile int signal_received = 0; @@ -338,6 +351,10 @@ exec_with_timeout(const char* cmd) } return status; } +#else // !ENABLE_TIMEOUT +#define exec_with_timeout(cmd) system(cmd) +#define setup_sig_handler() while (0); +#endif // !ENABLE_TIMEOUT namespace {