diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-06-08 17:16:48 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-06-08 17:16:48 +0200 |
commit | 45798927f8532cd412622e9762619b46a9b638cd (patch) | |
tree | e6407784ea2ce1902a20407fecddac3afaf56657 | |
parent | 33a76159433a5763ff6050cfaaee8fd897102639 (diff) |
udevd: print error if worker dies unexpectedly
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | udev/lib/libudev.h | 2 | ||||
-rw-r--r-- | udev/udevd.c | 27 |
3 files changed, 21 insertions, 11 deletions
@@ -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 diff --git a/udev/lib/libudev.h b/udev/lib/libudev.h index 207dd821a6..63cb478b8f 100644 --- a/udev/lib/libudev.h +++ b/udev/lib/libudev.h @@ -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); diff --git a/udev/udevd.c b/udev/udevd.c index 2e7a179cbc..e7a0c9840a 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -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 */ |