From 474b5a3a9a25f0aa12e69afd72d7661638ad879d Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Thu, 5 Apr 2018 16:51:19 +0200 Subject: [PATCH] script: fix possible negative delay Fix delay becoming negative when killing a running script Signed-off-by: Hans Dedecker --- src/script.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/script.c b/src/script.c index 5696b7f..fcdbb27 100644 --- a/src/script.c +++ b/src/script.c @@ -393,8 +393,15 @@ void script_call(const char *status, int delay, bool resume) bool running_script = false; if (running) { + time_t diff = now - started; + kill(running, SIGTERM); - delay -= now - started; + + if (diff > delay) + delay -= diff; + else + delay = 0; + running_script = true; } -- 2.25.1