aboutsummaryrefslogtreecommitdiff
path: root/src/rc/supervise-daemon.c
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-11-30 17:10:47 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-12-02 18:33:25 -0600
commit1b5a3b4ef4b2c3e20cfe4a71cf38c63279ed42d2 (patch)
tree067329cc2915f24e8470a52c24d2afdec8b3b383 /src/rc/supervise-daemon.c
parent77262c359c4aaf15ba00b07cd51f3987ce514769 (diff)
supervise-daemon: make respawn-max and respawn-period independent settings
Diffstat (limited to 'src/rc/supervise-daemon.c')
-rw-r--r--src/rc/supervise-daemon.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index bfbb85f6..d93d31f8 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -143,7 +143,7 @@ static pid_t child_pid;
static int respawn_count = 0;
static int respawn_delay = 0;
static int respawn_max = 10;
-static int respawn_period = 5;
+static int respawn_period = 0;
static char *fifopath = NULL;
static int fifo_fd = 0;
static char *pidfile = NULL;
@@ -563,23 +563,21 @@ static void supervisor(char *exec, char **argv)
do_healthcheck = 0;
healthcheck_respawn = 0;
alarm(0);
- if (respawn_max > 0 && respawn_period > 0) {
- respawn_now = time(NULL);
- if (first_spawn == 0)
- first_spawn = respawn_now;
- if (respawn_now - first_spawn > respawn_period) {
- respawn_count = 0;
- first_spawn = 0;
- } else
- respawn_count++;
- if (respawn_count > respawn_max) {
- syslog(LOG_WARNING,
- "respawned \"%s\" too many times, exiting", exec);
- exiting = 1;
- continue;
- }
+ respawn_now = time(NULL);
+ if (first_spawn == 0)
+ first_spawn = respawn_now;
+ if ((respawn_period > 0)
+ && (respawn_now - first_spawn > respawn_period)) {
+ respawn_count = 0;
+ first_spawn = 0;
+ } else
+ respawn_count++;
+ if (respawn_max > 0 && respawn_count > respawn_max) {
+ syslog(LOG_WARNING, "respawned \"%s\" too many times, exiting",
+ exec);
+ exiting = 1;
+ continue;
}
- alarm(0);
ts.tv_sec = respawn_delay;
ts.tv_nsec = 0;
nanosleep(&ts, NULL);
@@ -930,7 +928,7 @@ int main(int argc, char **argv)
0, false, true) > 0)
eerrorx("%s: %s is already running", applet, exec);
- if (respawn_delay * respawn_max > respawn_period)
+ if (respawn_period > 0 && respawn_delay * respawn_max > respawn_period)
ewarn("%s: Please increase the value of --respawn-period to more "
"than %d to avoid infinite respawning", applet,
respawn_delay * respawn_max);