]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/script.c
script: Launch script with correct action if last script call is terminated
[odhcp6c.git] / src / script.c
index 3d313cf4964e6ab2479a51c0ba062174258a7de7..f272c190afdaa3eb07a20c6c8c9a001557b717de 100644 (file)
@@ -353,13 +353,15 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
 void script_call(const char *status, int delay, bool resume)
 {
        time_t now = odhcp6c_get_milli_time() / 1000;
 void script_call(const char *status, int delay, bool resume)
 {
        time_t now = odhcp6c_get_milli_time() / 1000;
+       bool running_script = false;
 
        if (running) {
                kill(running, SIGTERM);
                delay -= now - started;
 
        if (running) {
                kill(running, SIGTERM);
                delay -= now - started;
+               running_script = true;
        }
 
        }
 
-       if (resume || !action[0])
+       if (resume || !running_script || !action[0])
                strncpy(action, status, sizeof(action) - 1);
 
        pid_t pid = fork();
                strncpy(action, status, sizeof(action) - 1);
 
        pid_t pid = fork();