udevd.c revision 9a73bd7cab019aa1b9b4342ce2abd51b6e50b085
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * Copyright (C) 2004-2012 Kay Sievers <kay@vrfy.org>
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * Copyright (C) 2004 Chris Friesen <chris_friesen@sympatico.ca>
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * Copyright (C) 2009 Canonical Ltd.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * Copyright (C) 2009 Scott James Remnant <scott@netsplit.com>
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * This program is free software: you can redistribute it and/or modify
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * it under the terms of the GNU General Public License as published by
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * the Free Software Foundation, either version 2 of the License, or
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * (at your option) any later version.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * This program is distributed in the hope that it will be useful,
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * GNU General Public License for more details.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * You should have received a copy of the GNU General Public License
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * along with this program. If not, see <http://www.gnu.org/licenses/>.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic bool arg_debug = false;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic int arg_daemonize = false;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic usec_t arg_event_timeout_usec = 180 * USEC_PER_SEC;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic usec_t arg_event_timeout_warn_usec = 180 * USEC_PER_SEC / 3;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringtypedef struct Manager {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering struct udev_ctrl_connection *ctrl_conn_blocking;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering unsigned long long int delaying_seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering unsigned long long int seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic inline struct event *node_to_event(struct udev_list_node *node) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return container_of(node, struct event, node);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void event_queue_cleanup(Manager *manager, enum event_state type);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering/* passed from worker to main process */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void event_free(struct event *event) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void worker_free(struct worker *worker) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering hashmap_remove(worker->manager->workers, UINT_TO_PTR(worker->pid));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void manager_workers_free(Manager *manager) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering HASHMAP_FOREACH(worker, manager->workers, i)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering manager->workers = hashmap_free(manager->workers);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic int worker_new(struct worker **ret, Manager *manager, struct udev_monitor *worker_monitor, pid_t pid) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _cleanup_free_ struct worker *worker = NULL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* close monitor, but keep address around */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering worker->monitor = udev_monitor_ref(worker_monitor);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = hashmap_ensure_allocated(&manager->workers, NULL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = hashmap_put(manager->workers, UINT_TO_PTR(pid), worker);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void worker_attach_event(struct worker *worker, struct event *event) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->start_usec = now(CLOCK_MONOTONIC);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering return loop_write(fd, &message, sizeof(message), false);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void worker_spawn(Manager *manager, struct event *event) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _cleanup_udev_monitor_unref_ struct udev_monitor *worker_monitor = NULL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* listen for new events */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering worker_monitor = udev_monitor_new_from_netlink(udev, NULL);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* allow the main daemon netlink address to send devices to the worker */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_monitor_allow_unicast_sender(worker_monitor, manager->monitor);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_monitor_enable_receiving(worker_monitor);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering struct epoll_event ep_signal, ep_monitor;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* take initial device from queue */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event_queue_cleanup(manager, EVENT_UNDEF);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = log_error_errno(errno, "error creating signalfd %m");
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek fd_ep = epoll_create1(EPOLL_CLOEXEC);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = log_error_errno(errno, "error creating epoll fd: %m");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering memzero(&ep_signal, sizeof(struct epoll_event));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering fd_monitor = udev_monitor_get_fd(worker_monitor);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering memzero(&ep_monitor, sizeof(struct epoll_event));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = log_error_errno(errno, "fail to add fds to epoll: %m");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* request TERM signal if parent exits */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* reset OOM score, we only protect the main daemon */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering write_string_file("/proc/self/oom_score_adj", "0");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_debug("seq %llu running", udev_device_get_seqnum(dev));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* needed for SIGCHLD/SIGTERM in spawn() */
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek udev_event->exec_delay = arg_exec_delay;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * Take a shared lock on the device node; this establishes
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * a concept of device "ownership" to serialize device
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * access. External processes holding an exclusive lock will
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * cause udev to skip the event handling; in the case udev
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * acquired the lock, the external process can block until
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering * udev has finished its event handling.
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (!streq_ptr(udev_device_get_action(dev), "remove") &&
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering streq_ptr("block", udev_device_get_subsystem(dev)) &&
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering !startswith(udev_device_get_sysname(dev), "dm-") &&
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering !startswith(udev_device_get_sysname(dev), "md")) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (streq_ptr("partition", udev_device_get_devtype(d)))
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek fd_lock = open(udev_device_get_devnode(d), O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek if (fd_lock >= 0 && flock(fd_lock, LOCK_SH|LOCK_NB) < 0) {
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek log_debug_errno(errno, "Unable to flock(%s), skipping event handling: %m", udev_device_get_devnode(d));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* needed for renaming netifs */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* apply rules, create node, symlinks */
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering arg_event_timeout_usec, arg_event_timeout_warn_usec,
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek arg_event_timeout_usec, arg_event_timeout_warn_usec,
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* in case rtnl was initialized */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* apply/restore inotify watch */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* send processed event back to libudev listeners */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_monitor_send_device(worker_monitor, NULL, dev);
80343dc19a9bcd703275ad2ad88f43e5310559d6Zbigniew Jędrzejewski-Szmek log_debug("seq %llu processed", udev_device_get_seqnum(dev));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* send udevd the result of the event execution */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = worker_send_message(worker_watch[WRITE_END]);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_error_errno(r, "failed to send result of seq %llu to main daemon: %m",
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* wait for more device messages from main udevd, or term signal */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), -1);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = log_error_errno(errno, "failed to poll: %m");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering for (i = 0; i < fdcount; i++) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (ev[i].data.fd == fd_monitor && ev[i].events & EPOLLIN) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering dev = udev_monitor_receive_device(worker_monitor);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering } else if (ev[i].data.fd == fd_signal && ev[i].events & EPOLLIN) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering size = read(fd_signal, &fdsi, sizeof(struct signalfd_siginfo));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (size != sizeof(struct signalfd_siginfo))
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering _exit(r < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering log_error_errno(errno, "fork of child failed: %m");
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering r = worker_new(&worker, manager, worker_monitor, pid);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_debug("seq %llu forked new worker ["PID_FMT"]", udev_device_get_seqnum(event->dev), pid);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void event_run(Manager *manager, struct event *event) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering HASHMAP_FOREACH(worker, manager->workers, i) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering count = udev_monitor_send_device(manager->monitor, worker->monitor, event->dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_error_errno(errno, "worker ["PID_FMT"] did not accept message %zi (%m), kill it",
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (hashmap_size(manager->workers) >= arg_children_max) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_debug("maximum number (%i) of children reached", hashmap_size(manager->workers));
83f6936a018b08880670838756e0f4e9ea98b4a7Lennart Poettering /* start new worker and pass initial device */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic int event_queue_insert(Manager *manager, struct udev_device *dev) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->dev_kernel = udev_device_shallow_clone(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_device_copy_properties(event->dev_kernel, dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->seqnum = udev_device_get_seqnum(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->devpath = udev_device_get_devpath(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->devpath_len = strlen(event->devpath);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->devpath_old = udev_device_get_devpath_old(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->devnum = udev_device_get_devnum(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->is_block = streq("block", udev_device_get_subsystem(dev));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->ifindex = udev_device_get_ifindex(dev);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev),
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_device_get_action(dev), udev_device_get_subsystem(dev));
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_list_node_append(&event->node, &manager->events);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic void manager_kill_workers(Manager *manager) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering HASHMAP_FOREACH(worker, manager->workers, i) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering/* lookup event for identical, parent, child device */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poetteringstatic bool is_devpath_busy(Manager *manager, struct event *event) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* check if queue contains events we depend on */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering udev_list_node_foreach(loop, &manager->events) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering struct event *loop_event = node_to_event(loop);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* we already found a later event, earlier can not block us, no need to check again */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (loop_event->seqnum < event->delaying_seqnum)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* event we checked earlier still exists, no need to check again */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (loop_event->seqnum == event->delaying_seqnum)
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* found ourself, no later event can block us */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (loop_event->seqnum >= event->seqnum)
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (major(event->devnum) != 0 && event->devnum == loop_event->devnum && event->is_block == loop_event->is_block)
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* check network device ifindex */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (event->ifindex != 0 && event->ifindex == loop_event->ifindex)
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* check our old name */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (event->devpath_old != NULL && streq(loop_event->devpath, event->devpath_old)) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek event->delaying_seqnum = loop_event->seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* compare devpath */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering common = MIN(loop_event->devpath_len, event->devpath_len);
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* one devpath is contained in the other? */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (memcmp(loop_event->devpath, event->devpath, common) != 0)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* identical device event found */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (loop_event->devpath_len == event->devpath_len) {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* devices names might have changed/swapped in the meantime */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (major(event->devnum) != 0 && (event->devnum != loop_event->devnum || event->is_block != loop_event->is_block))
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (event->ifindex != 0 && event->ifindex != loop_event->ifindex)
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* parent device event found */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* child device event found */
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering if (loop_event->devpath[common] == '/') {
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering event->delaying_seqnum = loop_event->seqnum;
d4205751d4643c272059a3728045929dd0e5e800Lennart Poettering /* no matching device */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmekstatic void event_queue_start(Manager *manager) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek udev_list_node_foreach(loop, &manager->events) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek struct event *event = node_to_event(loop);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (event->state != EVENT_QUEUED)
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek /* do not start event if parent or child event is still running */
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (is_devpath_busy(manager, event))
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmekstatic void event_queue_cleanup(Manager *manager, enum event_state match_type) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek struct udev_list_node *loop, *tmp;
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek udev_list_node_foreach_safe(loop, tmp, &manager->events) {
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek struct event *event = node_to_event(loop);
54b7254c1fa629937f92fd6fa34bdf127b696a00Zbigniew Jędrzejewski-Szmek if (match_type != EVENT_UNDEF && match_type != event->state)
} control = {};
if (size < 0) {
if (!worker) {
if (dev) {
const char *str;
if (!ctrl_conn)
if (!ctrl_msg)
if (key) {
char *val;
arg_children_max = i;
bool part_table_read = false;
bool has_partitions = false;
int fd;
if (fd >= 0) {
part_table_read = true;
return -ENOMEM;
r = udev_enumerate_scan_devices(e);
has_partitions = true;
struct inotify_event *e;
ssize_t l;
if (!dev)
static int on_request_reload(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
int status;
if (pid <= 0)
if (!worker) {
log_warning("worker ["PID_FMT"] terminated by signal %i (%s)", pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
int fd, n;
n = sd_listen_fds(true);
if (ctrl >= 0)
if (netlink >= 0)
* udev.children-max=<number of workers> events are fully serialized if set to 1
if (!value)
int prio;
static void help(void) {
arg_daemonize = true;
arg_debug = true;
arg_resolve_names = 0;
help();
return -EINVAL;
if (!manager)
if (!manager)
return log_oom();
log_open();
goto exit;
if (arg_debug)
if (getuid() != 0) {
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
if (arg_daemonize) {
int fd;
if (fd >= 0) {
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
goto exit;
if (arg_daemonize) {
switch (pid) {
goto exit;
goto exit_daemonize;
setsid();
if (arg_children_max == 0) {
if (fd_inotify < 0) {
goto exit;
if (fd_signal < 0) {
goto exit;
goto exit;
if (fd_ep < 0) {
goto exit;
goto exit;
int fdcount;
int timeout;
if (fd_ctrl >= 0) {
if (fd_inotify >= 0) {
if (fdcount < 0)
if (fdcount == 0) {
Iterator j;
for (i = 0; i < fdcount; i++) {
is_worker = true;
is_netlink = true;
is_signal = true;
is_inotify = true;
is_ctrl = true;
if (is_worker)
if (is_netlink)
if (is_signal) {
case SIGINT:
case SIGTERM:
case SIGHUP:
case SIGCHLD:
if (is_inotify)
if (is_ctrl)
exit:
if (fd_ep >= 0)
if (fd_signal >= 0)
log_close();