diff options
author | June McEnroe <june@causal.agency> | 2020-08-15 18:25:40 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-08-15 18:25:40 -0400 |
commit | 497cafbf0f2e96c21539fcc65b149450de262be8 (patch) | |
tree | b464fc74478038c30562afc5f5cea9721c762aea /daemon.c | |
parent | Log when service name pattern doesn't match (diff) | |
download | catsit-497cafbf0f2e96c21539fcc65b149450de262be8.tar.gz catsit-497cafbf0f2e96c21539fcc65b149450de262be8.zip |
Add reset interval after which restart interval is reset
Diffstat (limited to '')
-rw-r--r-- | daemon.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/daemon.c b/daemon.c index 3cfe24f..2e58c82 100644 --- a/daemon.c +++ b/daemon.c @@ -48,8 +48,9 @@ #define WS " \t" -struct timespec restartInterval = { .tv_sec = 1 }; struct Set256 stopExits; +struct timespec restartInterval = { .tv_sec = 1 }; +struct timespec resetInterval = { .tv_sec = 15 * 60 }; static volatile sig_atomic_t signals[NSIG]; static void signalHandler(int signal) { @@ -176,10 +177,10 @@ static void parseExits(char *list) { } } -static void parseInterval(const char *millis) { +static void parseInterval(struct timespec *interval, const char *millis) { unsigned long ms = strtoul(millis, NULL, 10); - restartInterval.tv_sec = ms / 1000; - restartInterval.tv_nsec = 1000000 * (ms % 1000); + interval->tv_sec = ms / 1000; + interval->tv_nsec = 1000000 * (ms % 1000); } static void setTitle(void) { @@ -208,7 +209,7 @@ int main(int argc, char *argv[]) { const char *userName = NULL; const char *groupName = NULL; - for (int opt; 0 < (opt = getopt(argc, argv, "C:c:df:g:p:s:t:u:"));) { + for (int opt; 0 < (opt = getopt(argc, argv, "C:c:df:g:p:r:s:t:u:"));) { switch (opt) { break; case 'C': serviceDir = optarg; break; case 'c': fifoPath = optarg; @@ -216,8 +217,9 @@ int main(int argc, char *argv[]) { break; case 'f': configPath = optarg; break; case 'g': groupName = optarg; break; case 'p': pidPath = optarg; + break; case 'r': parseInterval(&resetInterval, optarg); break; case 's': parseExits(optarg); - break; case 't': parseInterval(optarg); + break; case 't': parseInterval(&restartInterval, optarg); break; case 'u': userName = optarg; break; default: return EX_USAGE; } |