Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/
Date: Sat, 06 Oct 2018 18:03:39
Message-Id: 1538848264.eca4357892315ca7340bbfc2b373d7660a34142f.williamh@OpenRC
1 commit: eca4357892315ca7340bbfc2b373d7660a34142f
2 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
3 AuthorDate: Sat Oct 6 17:51:04 2018 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 6 17:51:04 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=eca43578
7
8 supervise-daemon: use nanosleep() instead of sleep()
9
10 We will be using sigalrm in this process for health checking, and
11 sigalrm cannot be used with sleep() safely.
12
13 src/rc/supervise-daemon.c | 5 ++++-
14 1 file changed, 4 insertions(+), 1 deletion(-)
15
16 diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
17 index 8d56b8d4..24cc56fa 100644
18 --- a/src/rc/supervise-daemon.c
19 +++ b/src/rc/supervise-daemon.c
20 @@ -425,6 +425,7 @@ static void supervisor(char *exec, char **argv)
21 FILE *fp;
22 int i;
23 int nkilled;
24 + struct timespec ts;
25 time_t respawn_now= 0;
26 time_t first_spawn= 0;
27
28 @@ -497,7 +498,9 @@ static void supervisor(char *exec, char **argv)
29 if (nkilled > 0)
30 syslog(LOG_INFO, "killed %d processes", nkilled);
31 } else {
32 - sleep(respawn_delay);
33 + ts.tv_sec = respawn_delay;
34 + ts.tv_nsec = 0;
35 + nanosleep(&ts, NULL);
36 if (respawn_max > 0 && respawn_period > 0) {
37 respawn_now = time(NULL);
38 if (first_spawn == 0)