aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rc/supervise-daemon.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 7b894e7b..2800d1a2 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -432,6 +432,7 @@ int main(int argc, char **argv)
int respawn_period = 5;
time_t respawn_now= 0;
time_t first_spawn= 0;
+ struct timespec ts;
struct passwd *pw;
struct group *gr;
FILE *fp;
@@ -658,17 +659,18 @@ int main(int argc, char **argv)
if (stop) {
pid = get_pid(applet, pidfile);
- if (pid == -1)
- i = pid;
- else
+ if (pid != -1) {
i = kill(pid, SIGTERM);
- if (i != 0)
- /* We failed to send the signal */
- exit(EXIT_FAILURE);
-
- /* wait for the supervisor to go down */
- while (kill(pid, 0) == 0)
- sleep(1);
+ if (i != 0)
+ /* We failed to send the signal */
+ exit(EXIT_FAILURE);
+
+ /* wait for the supervisor to go down */
+ while (kill(pid, 0) == 0)
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1;
+ nanosleep(&ts, NULL);
+ }
/* Even if we have not actually killed anything, we should
* remove information about it as it may have unexpectedly