diff options
author | June McEnroe <june@causal.agency> | 2020-08-15 09:53:03 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-08-15 09:53:03 -0400 |
commit | f39d916e3a35527eb0d886506ac6fc70fa639070 (patch) | |
tree | 0fb74809fd14dbc03cf07fe7907fc3277ce186e2 /daemon.c | |
parent | Reap children (diff) | |
download | catsit-f39d916e3a35527eb0d886506ac6fc70fa639070.tar.gz catsit-f39d916e3a35527eb0d886506ac6fc70fa639070.zip |
Just use CLOCK_MONOTONIC and clean up includes
CLOCK_MONOTONIC exists everywhere.
Diffstat (limited to '')
-rw-r--r-- | daemon.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/daemon.c b/daemon.c index cd12f92..9eb8bb4 100644 --- a/daemon.c +++ b/daemon.c @@ -29,7 +29,6 @@ #include <string.h> #include <sys/stat.h> #include <sys/time.h> -#include <sys/timespec.h> #include <sys/wait.h> #include <sysexits.h> #include <syslog.h> @@ -266,7 +265,7 @@ int main(int argc, char *argv[]) { struct timespec now = {0}; struct timespec timeout = {0}; if (timespecisset(&deadline)) { - clock_gettime(CLOCK_MONOTONIC_FAST, &now); + clock_gettime(CLOCK_MONOTONIC, &now); timespecsub(&deadline, &now, &timeout); } if (timeout.tv_sec < 0 || timeout.tv_nsec < 0) { @@ -281,13 +280,15 @@ int main(int argc, char *argv[]) { // TODO: Handle FIFO and pipes. - clock_gettime(CLOCK_MONOTONIC_FAST, &now); - for (size_t i = 0; i < services.len; ++i) { - struct Service *service = &services.ptr[i]; - if (service->intent != Start) continue; - if (service->state == Start) continue; - if (timespeccmp(&service->restartDeadline, &now, <=)) { - serviceStart(service); + if (timespecisset(&deadline)) { + clock_gettime(CLOCK_MONOTONIC, &now); + for (size_t i = 0; i < services.len; ++i) { + struct Service *service = &services.ptr[i]; + if (service->intent != Start) continue; + if (service->state == Start) continue; + if (timespeccmp(&service->restartDeadline, &now, <=)) { + serviceStart(service); + } } } |