chiark / gitweb /
util: introduce waitpid_loop()
[elogind.git] / src / util.c
index ec3df946424d57ed3bec12ebcaddad3b45d4c971..805d47afb43f505b156ea2af9c7e2950067d4536 100644 (file)
@@ -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"
@@ -2835,6 +2836,7 @@ void status_welcome(void) {
 
         status_printf("Welcome to \x1B[0;32m%s\x1B[0m!\n", r); /* Green for SUSE */
         free(r);
+
 #elif defined(TARGET_GENTOO)
         char *r;
 
@@ -2846,6 +2848,20 @@ void status_welcome(void) {
         status_printf("Welcome to \x1B[1;34m%s\x1B[0m!\n", r); /* Light Blue for Gentoo */
 
         free(r);
+
+#elif defined(TARGET_DEBIAN)
+        char *r;
+
+        if (read_one_line_file("/etc/debian_version", &r) < 0)
+                return;
+
+        truncate_nl(r);
+
+        status_printf("Welcome to Debian \x1B[1;31m%s\x1B[0m!\n", r); /* Light Red for Debian */
+
+        free(r);
+#elif defined(TARGET_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
@@ -3085,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",
@@ -3199,7 +3232,9 @@ static const char *const signal_table[] = {
         [SIGPIPE] = "PIPE",
         [SIGALRM] = "ALRM",
         [SIGTERM] = "TERM",
-        [SIGSTKFLT] = "STKFLT",
+#ifdef SIGSTKFLT
+        [SIGSTKFLT] = "STKFLT",  /* Linux on SPARC doesn't know SIGSTKFLT */
+#endif
         [SIGCHLD] = "CHLD",
         [SIGCONT] = "CONT",
         [SIGSTOP] = "STOP",