From: Hans Dedecker Date: Thu, 5 Apr 2018 14:51:19 +0000 (+0200) Subject: script: fix possible negative delay X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=474b5a3a9a25f0aa12e69afd72d7661638ad879d;p=project%2Fodhcp6c.git script: fix possible negative delay Fix delay becoming negative when killing a running script Signed-off-by: Hans Dedecker --- 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; }