From eca4357892315ca7340bbfc2b373d7660a34142f Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sat, 6 Oct 2018 12:51:04 -0500 Subject: 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. --- src/rc/supervise-daemon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3