summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kmod-setup.c13
-rw-r--r--src/util.c32
-rw-r--r--src/util.h2
3 files changed, 29 insertions, 18 deletions
diff --git a/src/kmod-setup.c b/src/kmod-setup.c
index e614295f37..0bcad3ceb4 100644
--- a/src/kmod-setup.c
+++ b/src/kmod-setup.c
@@ -76,17 +76,8 @@ int kmod_setup(void) {
if (r < 0)
return r;
- for (;;) {
- if (waitpid(pid, &status, 0) < 0) {
-
- if (errno == EINTR)
- continue;
-
- return -errno;
- }
-
- break;
- }
+ if ((r = waitpid_loop(pid, &status)) < 0)
+ return -errno;
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) != 0) {
diff --git a/src/util.c b/src/util.c
index 48cdb19ef1..805d47afb4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -49,6 +49,7 @@
#include <netinet/ip.h>
#include <linux/kd.h>
#include <dlfcn.h>
+#include <sys/wait.h>
#include "macro.h"
#include "util.h"
@@ -2849,18 +2850,18 @@ void status_welcome(void) {
free(r);
#elif defined(TARGET_DEBIAN)
- char *r;
+ char *r;
- if (read_one_line_file("/etc/debian_version", &r) < 0)
- return;
+ if (read_one_line_file("/etc/debian_version", &r) < 0)
+ return;
- truncate_nl(r);
+ truncate_nl(r);
- status_printf("Welcome to Debian \x1B[1;31m%s\x1B[0m!\n", r); /* Light Red for Debian */
+ status_printf("Welcome to Debian \x1B[1;31m%s\x1B[0m!\n", r); /* Light Red for Debian */
- free(r);
+ free(r);
#elif defined(TARGET_ARCH)
- status_printf("Welcome to \x1B[1;36mArch Linux\x1B[0m!\n"); /* Cyan for Arch */
+ status_printf("Welcome to \x1B[1;36mArch Linux\x1B[0m!\n"); /* Cyan for Arch */
#else
#warning "You probably should add a welcome text logic here."
#endif
@@ -3100,6 +3101,23 @@ char *unquote(const char *s, const char quote) {
return strdup(s);
}
+int waitpid_loop(pid_t pid, int *status) {
+ assert(pid >= 1);
+ assert(status);
+
+ for (;;) {
+ if (waitpid(pid, status, 0) < 0) {
+
+ if (errno == EINTR)
+ continue;
+
+ return -errno;
+ }
+
+ return 0;
+ }
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",
diff --git a/src/util.h b/src/util.h
index 3a7ac29fca..4bea1ecc04 100644
--- a/src/util.h
+++ b/src/util.h
@@ -345,6 +345,8 @@ int touch(const char *path);
char *unquote(const char *s, const char quote);
+int waitpid_loop(pid_t pid, int *status);
+
#define NULSTR_FOREACH(i, l) \
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)