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