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:41
Message-Id: 1538848184.7ee3e5b2d6dbb9c279011b59ec132d27d04f843e.williamh@OpenRC
1 commit: 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e
2 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
3 AuthorDate: Sat Oct 6 17:49:44 2018 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 6 17:49:44 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=7ee3e5b2
7
8 openrc-init: convert sleep() call to nanosleep()
9
10 Nanosleep is the safer call to use in case we need to use alarms
11 eventually.
12
13 src/rc/openrc-init.c | 6 +++++-
14 1 file changed, 5 insertions(+), 1 deletion(-)
15
16 diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
17 index d8038637..e02fa5ee 100644
18 --- a/src/rc/openrc-init.c
19 +++ b/src/rc/openrc-init.c
20 @@ -24,6 +24,7 @@
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 +#include <time.h>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 @@ -96,12 +97,15 @@ static void handle_reexec(char *my_name)
29 static void handle_shutdown(const char *runlevel, int cmd)
30 {
31 pid_t pid;
32 + struct timespec ts;
33
34 pid = do_openrc(runlevel);
35 while (waitpid(pid, NULL, 0) != pid);
36 printf("Sending the final term signal\n");
37 kill(-1, SIGTERM);
38 - sleep(3);
39 + ts.tv_sec = 3;
40 + ts.tv_nsec = 0;
41 + nanosleep(&ts, NULL);
42 printf("Sending the final kill signal\n");
43 kill(-1, SIGKILL);
44 sync();