From e57326832ebea2a5a9b8d34cf30b191dc4d268ae Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Wed, 20 Nov 2019 12:01:52 +0800 Subject: [PATCH] update timeout checks --- src/reset_timeout.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/reset_timeout.c b/src/reset_timeout.c index db54ce0cc..7c14ab1c3 100644 --- a/src/reset_timeout.c +++ b/src/reset_timeout.c @@ -19,19 +19,22 @@ void reset_binary_c_timeout(void) { #ifndef __HAVE_SETITIMER__ - /* - * We don't have setitimer but we do want a timeout: - * exit with a warning. - */ - Exit_binary_c_no_stardata(BINARY_C_TIMED_OUT, - "TIMEOUT_SECONDS is set to %ld but we have no access to setitimer to actually set the timeout. This will cause binary_c to not have a timeout, even though you have asked for it. Please set TIMEOUT_SECONDS to 0 in binary_c_code_options.h to fix this problem, or build on an operating system that supports setitimer.", - (long int)TIMEOUT_SECONDS); - + if(TIMEOUT_SECONDS != 0) + { + /* + * We don't have setitimer but we do want a timeout: + * exit with a warning. + */ + Exit_binary_c_no_stardata(BINARY_C_TIMED_OUT, + "TIMEOUT_SECONDS is set to %ld but we have no access to setitimer to actually set the timeout. This will cause binary_c to not have a timeout, even though you have asked for it. Please set TIMEOUT_SECONDS to 0 in binary_c_code_options.h to fix this problem, or build on an operating system that supports setitimer.", + (long int)TIMEOUT_SECONDS); + } #else /* - * We have setitimer + * We have setitimer, so if TIMEOUT_SECONDS is non-zero, + * set the timer. */ - if(TIMEOUT_SECONDS) + if(TIMEOUT_SECONDS != 0) { /* Timing */ struct itimerval value; @@ -66,7 +69,11 @@ void reset_binary_c_timeout(void) void disable_binary_c_timeout(void) { #ifdef __HAVE_SETITIMER__ - if(TIMEOUT_SECONDS) + /* + * disable the timer if it could have been set (i.e. if + * TIMEOUT_SECONDS is non-zero) + */ + if(TIMEOUT_SECONDS != 0) { struct itimerval value; struct timeval tv; -- GitLab