2015-06-10 17:30:16 +00:00
|
|
|
From 8300a7a170f44490d4e86541fbbad2b90cd52ce0 Mon Sep 17 00:00:00 2001
|
2015-05-27 21:16:29 +00:00
|
|
|
From: Tom Gundersen <teg@jklm.no>
|
|
|
|
Date: Wed, 27 May 2015 18:39:36 +0200
|
|
|
|
Subject: [PATCH] udevd: fix SIGCHLD handling in --daemon mode
|
|
|
|
|
|
|
|
We were listening for SIGCHLD in the wrong process.
|
2015-06-10 17:30:16 +00:00
|
|
|
|
|
|
|
(cherry picked from commit 86c3bece38bcf55da6387d20c6f01da9ad0284dc)
|
2015-05-27 21:16:29 +00:00
|
|
|
---
|
|
|
|
src/udev/udevd.c | 33 ++++++++++++++++++++++-----------
|
|
|
|
1 file changed, 22 insertions(+), 11 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
|
2015-06-10 17:30:16 +00:00
|
|
|
index 2a9a429e66..b5dadbc8e4 100644
|
2015-05-27 21:16:29 +00:00
|
|
|
--- a/src/udev/udevd.c
|
|
|
|
+++ b/src/udev/udevd.c
|
2015-06-10 17:30:16 +00:00
|
|
|
@@ -1289,13 +1289,6 @@ static int parse_argv(int argc, char *argv[]) {
|
2015-05-27 21:16:29 +00:00
|
|
|
|
|
|
|
static int manager_new(Manager **ret) {
|
|
|
|
_cleanup_(manager_freep) Manager *manager = NULL;
|
|
|
|
- struct epoll_event ep_ctrl = { .events = EPOLLIN };
|
|
|
|
- struct epoll_event ep_inotify = { .events = EPOLLIN };
|
|
|
|
- struct epoll_event ep_signal = { .events = EPOLLIN };
|
|
|
|
- struct epoll_event ep_netlink = { .events = EPOLLIN };
|
|
|
|
- struct epoll_event ep_worker = { .events = EPOLLIN };
|
|
|
|
- sigset_t mask;
|
|
|
|
- int r, one = 1;
|
|
|
|
|
|
|
|
assert(ret);
|
|
|
|
|
2015-06-10 17:30:16 +00:00
|
|
|
@@ -1324,6 +1317,23 @@ static int manager_new(Manager **ret) {
|
2015-05-27 21:16:29 +00:00
|
|
|
udev_list_node_init(&manager->events);
|
|
|
|
udev_list_init(manager->udev, &manager->properties, true);
|
|
|
|
|
|
|
|
+ *ret = manager;
|
|
|
|
+ manager = NULL;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int manager_listen(Manager *manager) {
|
|
|
|
+ struct epoll_event ep_ctrl = { .events = EPOLLIN };
|
|
|
|
+ struct epoll_event ep_inotify = { .events = EPOLLIN };
|
|
|
|
+ struct epoll_event ep_signal = { .events = EPOLLIN };
|
|
|
|
+ struct epoll_event ep_netlink = { .events = EPOLLIN };
|
|
|
|
+ struct epoll_event ep_worker = { .events = EPOLLIN };
|
|
|
|
+ sigset_t mask;
|
|
|
|
+ int r, one = 1;
|
|
|
|
+
|
|
|
|
+ assert(manager);
|
|
|
|
+
|
|
|
|
r = systemd_fds(&manager->fd_ctrl, &manager->fd_uevent);
|
|
|
|
if (r >= 0) {
|
|
|
|
/* get control and netlink socket from systemd */
|
2015-06-10 17:30:16 +00:00
|
|
|
@@ -1405,10 +1415,7 @@ static int manager_new(Manager **ret) {
|
2015-05-27 21:16:29 +00:00
|
|
|
epoll_ctl(manager->fd_ep, EPOLL_CTL_ADD, manager->fd_worker, &ep_worker) < 0)
|
|
|
|
return log_error_errno(errno, "fail to add fds to epoll: %m");
|
|
|
|
|
|
|
|
- *ret = manager;
|
|
|
|
- manager = NULL;
|
|
|
|
-
|
|
|
|
- return 1;
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2015-06-10 17:30:16 +00:00
|
|
|
@@ -1519,6 +1526,10 @@ int main(int argc, char *argv[]) {
|
2015-05-27 21:16:29 +00:00
|
|
|
} else
|
|
|
|
sd_notify(1, "READY=1");
|
|
|
|
|
|
|
|
+ r = manager_listen(manager);
|
|
|
|
+ if (r < 0)
|
|
|
|
+ return log_error_errno(r, "failed to set up fds and listen for events: %m");
|
|
|
|
+
|
|
|
|
for (;;) {
|
|
|
|
static usec_t last_usec;
|
|
|
|
struct epoll_event ev[8];
|