[systemd-commits] 2 commits - fixme src/kmod-setup.c src/main.c src/util.c src/util.h
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Sep 15 05:49:05 PDT 2010
fixme | 14 ++++++++++----
src/kmod-setup.c | 29 +++++++++++------------------
src/main.c | 9 +++++----
src/util.c | 34 +++++++++++++++++++++++++++-------
src/util.h | 2 ++
5 files changed, 55 insertions(+), 33 deletions(-)
New commits:
commit 8e12a6aed3d99ac8c140cd56b560f5efeb1c4e1a
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Sep 15 14:48:59 2010 +0200
util: use waitid() instead of waitpid() everywhere to avoid confusion due to SIGSTOP
diff --git a/src/kmod-setup.c b/src/kmod-setup.c
index 0bcad3c..44d843d 100644
--- a/src/kmod-setup.c
+++ b/src/kmod-setup.c
@@ -41,7 +41,8 @@ int kmod_setup(void) {
ExecCommand command;
ExecContext context;
pid_t pid;
- int status, r;
+ int r;
+ siginfo_t status;
for (i = 0; i < ELEMENTSOF(kmod_table); i += 2) {
@@ -76,21 +77,22 @@ int kmod_setup(void) {
if (r < 0)
return r;
- if ((r = waitpid_loop(pid, &status)) < 0)
+ if ((r = wait_for_terminate(pid, &status)) < 0)
return -errno;
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0) {
- log_warning("/sbin/modprobe failed with error code %i.", WEXITSTATUS(status));
+ if (status.si_code == CLD_EXITED) {
+ if (status.si_status != 0) {
+ log_warning("/sbin/modprobe failed with error code %i.", status.si_status);
return -EPROTO;
}
log_debug("/sbin/modprobe succeeded.");
return 0;
- }
- if (WIFSIGNALED(status)) {
- log_warning("/sbin/modprobe terminated by signal %s.", signal_to_string(WTERMSIG(status)));
+ } else if (status.si_code == CLD_KILLED ||
+ status.si_code == CLD_DUMPED) {
+
+ log_warning("/sbin/modprobe terminated by signal %s.", signal_to_string(status.si_status));
return -EPROTO;
}
diff --git a/src/main.c b/src/main.c
index dc561a9..e4f229e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -119,12 +119,13 @@ _noreturn_ static void crash(int sig) {
_exit(1);
} else {
- int status;
+ siginfo_t status;
+ int r;
/* Order things nicely. */
- if (waitpid(pid, &status, 0) < 0)
- log_error("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(errno));
- else if (!WCOREDUMP(status))
+ if ((r = wait_for_terminate(pid, &status)) < 0)
+ log_error("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(-r));
+ else if (status.si_code != CLD_DUMPED)
log_error("Caught <%s>, core dump failed.", signal_to_string(sig));
else
log_error("Caught <%s>, dumped core as pid %lu.", signal_to_string(sig), (unsigned long) pid);
diff --git a/src/util.c b/src/util.c
index 805d47a..a3d6b49 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3101,12 +3101,14 @@ char *unquote(const char *s, const char quote) {
return strdup(s);
}
-int waitpid_loop(pid_t pid, int *status) {
+int wait_for_terminate(pid_t pid, siginfo_t *status) {
assert(pid >= 1);
assert(status);
for (;;) {
- if (waitpid(pid, status, 0) < 0) {
+ zero(*status);
+
+ if (waitid(P_PID, pid, status, WEXITED) < 0) {
if (errno == EINTR)
continue;
diff --git a/src/util.h b/src/util.h
index 4bea1ec..bdd4f15 100644
--- a/src/util.h
+++ b/src/util.h
@@ -345,7 +345,7 @@ int touch(const char *path);
char *unquote(const char *s, const char quote);
-int waitpid_loop(pid_t pid, int *status);
+int wait_for_terminate(pid_t pid, siginfo_t *status);
#define NULSTR_FOREACH(i, l) \
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
commit 2e78aa9988425d540a572535fa2e3d68ff519316
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Sep 15 14:37:16 2010 +0200
util: introduce waitpid_loop()
diff --git a/fixme b/fixme
index 2e7cd3b..bce501c 100644
--- a/fixme
+++ b/fixme
@@ -3,8 +3,6 @@
* read /etc/locale, and export LANG= and friends to started services
allow overwrite of setting by kernel commandline: locale.LANG=, ...
-* ABI: tcpwrap "legacy", disable D-Bus export if not compiled-in
-
* oneshot services which do not remain: 'exited' instead of 'dead'?
it should be visible in 'systemctl' that they have been run
@@ -88,6 +86,16 @@
* support dbus introspection in mid-level object paths, i.e. in /org/freedesktop/systemd/units/.
+* default.target auch in /lib linken
+
+* systemctl auto-pager a la git
+
+* console setup
+
+* fsck setup
+
+* merge CK
+
External:
* place /etc/inittab with explaining blurb.
@@ -100,8 +108,6 @@ External:
* make sysinit honour forcefsck/fastboot from the kernel command line fsck.mode=auto|force|skip
-* ck logging, ssd readahead
-
* pam: fix double sudo session cleanup:
http://www.gratisoft.us/bugzilla/show_bug.cgi?id=421
diff --git a/src/kmod-setup.c b/src/kmod-setup.c
index e614295..0bcad3c 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 48cdb19..805d47a 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 3a7ac29..4bea1ec 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)
More information about the systemd-commits
mailing list