]> err.no Git - systemd/commitdiff
udevd: print error if worker dies unexpectedly
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 8 Jun 2009 15:16:48 +0000 (17:16 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 8 Jun 2009 15:16:48 +0000 (17:16 +0200)
TODO
udev/lib/libudev.h
udev/udevd.c

diff --git a/TODO b/TODO
index dfbb18d0cc2fcf3c05017cfa8845e3a6e71bedba..af745ff5a2ec55ff24bfee66e281fdfee37ef75c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,10 +1,9 @@
 
-  o kill path_id.sh (add fc, sas, iscsi to C version)
+  o enumerate: sort control* after pcm*
   o add tests for kernel provided DEVNAME logic
   o drop modprobe floppy alias (SUSE), it will be in the module (2.6.30)
   o remove MMC rules, they got a modalias now (2.6.30)
   o add scsi:t-0x09* to "ch" and remove modprobe rule (2.6.30)
-
   o drop all support for the DEPRECATED sysfs layout
   o "udevadm control" commands will only accept the --<command> syntax
   o symlink names to udevadm will no longer be resolved to old command names
index 207dd821a6693fec59010ed00d4165c6397d710f..63cb478b8ffcf0a9978a3206af19dd902b32fb81 100644 (file)
@@ -74,7 +74,7 @@ const char *udev_device_get_action(struct udev_device *udev_device);
 unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
 const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
 
-/* udev and kernel device events */
+/* device events */
 struct udev_monitor;
 struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name);
 struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char *socket_path);
index 2e7a179cbc083d6a7a3818114c9cf80688a106dd..e7a0c9840aba4b23e71b0e36877c78bcf3bbdb6b 100644 (file)
@@ -159,6 +159,7 @@ static void event_queue_delete(struct event *event)
        else
                udev_queue_export_device_finished(udev_queue_export, event->dev);
 
+       info(event->udev, "seq %llu done with %i\n", udev_device_get_seqnum(event->dev), event->exitcode);
        udev_device_unref(event->dev);
        free(event);
 }
@@ -271,7 +272,7 @@ static void worker_new(struct event *event)
                        /* send processed event back to libudev listeners */
                        udev_monitor_send_device(worker_monitor, NULL, dev);
 
-                       info(event->udev, "seq %llu finished with %i\n", udev_device_get_seqnum(dev), err);
+                       info(event->udev, "seq %llu processed with %i\n", udev_device_get_seqnum(dev), err);
                        udev_device_unref(dev);
                        udev_event_unref(udev_event);
 
@@ -617,7 +618,7 @@ static int handle_inotify(struct udev *udev)
 
        buf = malloc(nbytes);
        if (buf == NULL) {
-               err(udev, "error getting buffer for inotify, disable watching\n");
+               err(udev, "error getting buffer for inotify\n");
                return -1;
        }
 
@@ -659,7 +660,7 @@ static int handle_inotify(struct udev *udev)
        return 0;
 }
 
-static void handle_signal(int signo)
+static void handle_signal(struct udev *udev, int signo)
 {
        switch (signo) {
        case SIGINT:
@@ -669,9 +670,10 @@ static void handle_signal(int signo)
        case SIGCHLD:
                while (1) {
                        pid_t pid;
+                       int status;
                        struct udev_list_node *loop, *tmp;
 
-                       pid = waitpid(-1, NULL, WNOHANG);
+                       pid = waitpid(-1, &status, WNOHANG);
                        if (pid <= 0)
                                break;
 
@@ -683,7 +685,16 @@ static void handle_signal(int signo)
 
                                /* fail event, if worker died unexpectedly */
                                if (worker->event != NULL) {
-                                       worker->event->exitcode = 127;
+                                       int exitcode;
+
+                                       if (WIFEXITED(status))
+                                               exitcode = WEXITSTATUS(status);
+                                       else if (WIFSIGNALED(status))
+                                               exitcode = WTERMSIG(status) + 128;
+                                       else
+                                               exitcode = 0;
+                                       worker->event->exitcode = exitcode;
+                                       err(udev, "worker [%u] unexpectedly returned with %i\n", pid, exitcode);
                                        event_queue_delete(worker->event);
                                }
 
@@ -938,9 +949,9 @@ int main(int argc, char *argv[])
 
        /* OOM_DISABLE == -17 */
        fd = open("/proc/self/oom_adj", O_RDWR);
-       if (fd < 0)
+       if (fd < 0) {
                err(udev, "error disabling OOM: %m\n");
-       else {
+       else {
                write(fd, "-17", 3);
                close(fd);
        }
@@ -1010,7 +1021,7 @@ int main(int argc, char *argv[])
 
                        size = read(pfd[FD_SIGNAL].fd, &fdsi, sizeof(struct signalfd_siginfo));
                        if (size == sizeof(struct signalfd_siginfo))
-                               handle_signal(fdsi.ssi_signo);
+                               handle_signal(udev, fdsi.ssi_signo);
                }
 
                /* device node and rules directory inotify watch */