diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2018-10-06 12:49:44 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2018-10-06 12:49:44 -0500 |
commit | 7ee3e5b2d6dbb9c279011b59ec132d27d04f843e (patch) | |
tree | 6d7dcc9e6d75a96017a181e0fb6f4f83a3c631e6 | |
parent | 7cb8d943236fe651ac54c64f8167f7c4369f649c (diff) |
openrc-init: convert sleep() call to nanosleep()
Nanosleep is the safer call to use in case we need to use alarms
eventually.
-rw-r--r-- | src/rc/openrc-init.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c index d8038637..e02fa5ee 100644 --- a/src/rc/openrc-init.c +++ b/src/rc/openrc-init.c @@ -24,6 +24,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> @@ -96,12 +97,15 @@ static void handle_reexec(char *my_name) static void handle_shutdown(const char *runlevel, int cmd) { pid_t pid; + struct timespec ts; pid = do_openrc(runlevel); while (waitpid(pid, NULL, 0) != pid); printf("Sending the final term signal\n"); kill(-1, SIGTERM); - sleep(3); + ts.tv_sec = 3; + ts.tv_nsec = 0; + nanosleep(&ts, NULL); printf("Sending the final kill signal\n"); kill(-1, SIGKILL); sync(); |