aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-10-06 12:51:04 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-10-06 12:51:04 -0500
commiteca4357892315ca7340bbfc2b373d7660a34142f (patch)
tree76a955a80fa0c37c99310a6b0069b20155c1c4f0 /src
parent7ee3e5b2d6dbb9c279011b59ec132d27d04f843e (diff)
supervise-daemon: use nanosleep() instead of sleep()
We will be using sigalrm in this process for health checking, and sigalrm cannot be used with sleep() safely.
Diffstat (limited to 'src')
-rw-r--r--src/rc/supervise-daemon.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 8d56b8d4..24cc56fa 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -425,6 +425,7 @@ static void supervisor(char *exec, char **argv)
FILE *fp;
int i;
int nkilled;
+ struct timespec ts;
time_t respawn_now= 0;
time_t first_spawn= 0;
@@ -497,7 +498,9 @@ static void supervisor(char *exec, char **argv)
if (nkilled > 0)
syslog(LOG_INFO, "killed %d processes", nkilled);
} else {
- sleep(respawn_delay);
+ ts.tv_sec = respawn_delay;
+ ts.tv_nsec = 0;
+ nanosleep(&ts, NULL);
if (respawn_max > 0 && respawn_period > 0) {
respawn_now = time(NULL);
if (first_spawn == 0)