2 * udevd.c - event listener and serializer
4 * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
5 * Copyright (C) 2004 Chris Friesen <chris_friesen@sympatico.ca>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation version 2 of the License.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 #include <sys/select.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
41 #include <sys/ioctl.h>
42 #include <linux/types.h>
43 #include <linux/netlink.h>
46 #include "udev_libc_wrapper.h"
48 #include "udev_version.h"
49 #include "udev_rules.h"
50 #include "udev_utils.h"
54 struct udev_rules rules;
55 static int udevd_sock;
56 static int uevent_netlink_sock;
57 static int inotify_fd;
60 static int signal_pipe[2] = {-1, -1};
61 static volatile int sigchilds_waiting;
62 static volatile int udev_exit;
63 static volatile int reload_config;
64 static int run_exec_q;
65 static int stop_exec_q;
66 static int max_childs;
67 static int max_childs_running;
68 static char udev_log[32];
70 static LIST_HEAD(exec_list);
71 static LIST_HEAD(running_list);
75 void log_message(int priority, const char *format, ...)
79 if (priority > udev_log_priority)
82 va_start(args, format);
83 vsyslog(priority, format, args);
88 static void asmlinkage udev_event_sig_handler(int signum)
90 if (signum == SIGALRM)
94 static int udev_event_process(struct uevent_msg *msg)
98 struct name_entry *name_loop;
102 /* set signal handlers */
103 memset(&act, 0x00, sizeof(act));
104 act.sa_handler = (void (*)(int)) udev_event_sig_handler;
105 sigemptyset (&act.sa_mask);
107 sigaction(SIGALRM, &act, NULL);
109 /* trigger timeout to prevent hanging processes */
110 alarm(UDEV_ALARM_TIMEOUT);
112 /* reconstruct env from message */
113 for (i = 0; msg->envp[i]; i++)
114 putenv(msg->envp[i]);
116 udev_init_device(&udev, msg->devpath, msg->subsystem, msg->action);
117 retval = udev_process_event(&rules, &udev);
119 /* run programs collected by RUN-key*/
121 list_for_each_entry(name_loop, &udev.run_list, node) {
122 if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
123 pass_env_to_socket(&name_loop->name[strlen("socket:")], msg->devpath, msg->action);
125 if (run_program(name_loop->name, udev.subsystem, NULL, 0, NULL,
126 (udev_log_priority >= LOG_INFO)))
131 udev_cleanup_device(&udev);
142 static void export_event_state(struct uevent_msg *msg, enum event_state state)
144 char filename[PATH_SIZE];
145 char filename_failed[PATH_SIZE];
146 char target[PATH_SIZE];
147 size_t start, end, i;
148 struct uevent_msg *loop_msg;
150 /* add location of queue files */
151 strlcpy(filename, udev_root, sizeof(filename));
152 strlcat(filename, "/", sizeof(filename));
153 start = strlcat(filename, EVENT_QUEUE_DIR, sizeof(filename));
154 end = strlcat(filename, msg->devpath, sizeof(filename));
155 if (end > sizeof(filename))
156 end = sizeof(filename);
158 /* replace '/' to transform path into a filename */
159 for (i = start+1; i < end; i++)
160 if (filename[i] == '/')
161 filename[i] = PATH_TO_NAME_CHAR;
163 /* add location of failed files */
164 strlcpy(filename_failed, udev_root, sizeof(filename_failed));
165 strlcat(filename_failed, "/", sizeof(filename_failed));
166 start = strlcat(filename_failed, EVENT_FAILED_DIR, sizeof(filename_failed));
167 end = strlcat(filename_failed, msg->devpath, sizeof(filename_failed));
168 if (end > sizeof(filename_failed))
169 end = sizeof(filename_failed);
171 /* replace '/' to transform path into a filename */
172 for (i = start+1; i < end; i++)
173 if (filename_failed[i] == '/')
174 filename_failed[i] = PATH_TO_NAME_CHAR;
178 unlink(filename_failed);
180 strlcpy(target, sysfs_path, sizeof(target));
181 strlcat(target, msg->devpath, sizeof(target));
182 create_path(filename);
183 symlink(target, filename);
186 unlink(filename_failed);
188 /* don't remove if events for the same path are still pending */
189 list_for_each_entry(loop_msg, &running_list, node)
190 if (loop_msg->devpath && strcmp(loop_msg->devpath, msg->devpath) == 0)
194 create_path(filename_failed);
195 rename(filename, filename_failed);
200 static void msg_queue_delete(struct uevent_msg *msg)
202 list_del(&msg->node);
204 /* mark as failed, if add event returns non-zero */
205 if (msg->exitstatus && strcmp(msg->action, "add") == 0)
206 export_event_state(msg, EVENT_FAILED);
208 export_event_state(msg, EVENT_FINISHED);
213 static void udev_event_run(struct uevent_msg *msg)
222 close(uevent_netlink_sock);
226 close(signal_pipe[READ_END]);
227 close(signal_pipe[WRITE_END]);
230 logging_init("udevd-event");
231 setpriority(PRIO_PROCESS, 0, UDEV_PRIORITY);
232 retval = udev_event_process(msg);
233 info("seq %llu finished", msg->seqnum);
240 err("fork of child failed: %s", strerror(errno));
241 msg_queue_delete(msg);
244 /* get SIGCHLD in main loop */
245 info("seq %llu forked, pid [%d], '%s' '%s', %ld seconds old",
246 msg->seqnum, pid, msg->action, msg->subsystem, time(NULL) - msg->queue_time);
251 static void msg_queue_insert(struct uevent_msg *msg)
253 msg->queue_time = time(NULL);
255 export_event_state(msg, EVENT_QUEUED);
257 /* run all events with a timeout set immediately */
258 if (msg->timeout != 0) {
259 list_add_tail(&msg->node, &running_list);
264 list_add_tail(&msg->node, &exec_list);
268 /* runs event and removes event from run queue when finished */
269 static int running_processes(void)
272 static char buf[4096];
277 f = open("/proc/stat", O_RDONLY);
281 len = read(f, buf, sizeof(buf)-1);
289 pos = strstr(buf, "procs_running ");
293 if (sscanf(pos, "procs_running %u", &running) != 1)
299 /* return the number of process es in our session, count only until limit */
300 static int running_processes_in_session(pid_t session, int limit)
306 dir = opendir("/proc");
310 /* read process info from /proc */
311 for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
317 pid_t ppid, pgrp, sess;
320 if (!isdigit(dent->d_name[0]))
323 snprintf(procdir, sizeof(procdir), "/proc/%s/stat", dent->d_name);
324 procdir[sizeof(procdir)-1] = '\0';
326 f = open(procdir, O_RDONLY);
330 len = read(f, line, sizeof(line)-1);
338 /* skip ugly program name */
339 pos = strrchr(line, ')') + 2;
343 if (sscanf(pos, "%c %d %d %d ", &state, &ppid, &pgrp, &sess) != 4)
346 /* count only processes in our session */
350 /* count only running, no sleeping processes */
355 if (limit > 0 && running >= limit)
363 static int compare_devpath(const char *running, const char *waiting)
367 for (i = 0; i < PATH_SIZE; i++) {
368 /* identical device event found */
369 if (running[i] == '\0' && waiting[i] == '\0')
372 /* parent device event found */
373 if (running[i] == '\0' && waiting[i] == '/')
376 /* child device event found */
377 if (running[i] == '/' && waiting[i] == '\0')
380 /* no matching event */
381 if (running[i] != waiting[i])
388 /* returns still running task for the same device, its parent or its physical device */
389 static int running_with_devpath(struct uevent_msg *msg, int limit)
391 struct uevent_msg *loop_msg;
392 int childs_count = 0;
394 list_for_each_entry(loop_msg, &running_list, node) {
395 if (limit && childs_count++ > limit) {
396 dbg("%llu, maximum number (%i) of child reached", msg->seqnum, childs_count);
400 /* return running parent/child device event */
401 if (compare_devpath(loop_msg->devpath, msg->devpath) != 0) {
402 dbg("%llu, child device event still running %llu (%s)",
403 msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
407 /* return running physical device event */
408 if (msg->physdevpath && msg->action && strcmp(msg->action, "add") == 0)
409 if (compare_devpath(loop_msg->devpath, msg->physdevpath) != 0) {
410 dbg("%llu, physical device event still running %llu (%s)",
411 msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
419 /* exec queue management routine executes the events and serializes events in the same sequence */
420 static void msg_queue_manager(void)
422 struct uevent_msg *loop_msg;
423 struct uevent_msg *tmp_msg;
426 if (list_empty(&exec_list))
429 running = running_processes();
430 dbg("%d processes runnning on system", running);
432 running = max_childs_running;
434 list_for_each_entry_safe(loop_msg, tmp_msg, &exec_list, node) {
435 /* check running processes in our session and possibly throttle */
436 if (running >= max_childs_running) {
437 running = running_processes_in_session(sid, max_childs_running+10);
438 dbg("at least %d processes running in session", running);
439 if (running >= max_childs_running) {
440 dbg("delay seq %llu, too many processes already running", loop_msg->seqnum);
445 /* don't run two processes for the same devpath and wait for the parent*/
446 if (running_with_devpath(loop_msg, max_childs)) {
447 dbg("delay seq %llu (%s)", loop_msg->seqnum, loop_msg->devpath);
451 /* move event to run list */
452 list_move_tail(&loop_msg->node, &running_list);
453 udev_event_run(loop_msg);
455 dbg("moved seq %llu to running list", loop_msg->seqnum);
459 static struct uevent_msg *get_msg_from_envbuf(const char *buf, int buf_size)
463 struct uevent_msg *msg;
467 msg = malloc(sizeof(struct uevent_msg) + buf_size);
470 memset(msg, 0x00, sizeof(struct uevent_msg) + buf_size);
472 /* copy environment buffer and reconstruct envp */
473 memcpy(msg->envbuf, buf, buf_size);
475 for (i = 0; (bufpos < buf_size) && (i < UEVENT_NUM_ENVP-2); i++) {
479 key = &msg->envbuf[bufpos];
480 keylen = strlen(key);
482 bufpos += keylen + 1;
483 dbg("add '%s' to msg.envp[%i]", msg->envp[i], i);
485 /* remember some keys for further processing */
486 if (strncmp(key, "ACTION=", 7) == 0)
487 msg->action = &key[7];
488 else if (strncmp(key, "DEVPATH=", 8) == 0)
489 msg->devpath = &key[8];
490 else if (strncmp(key, "SUBSYSTEM=", 10) == 0)
491 msg->subsystem = &key[10];
492 else if (strncmp(key, "SEQNUM=", 7) == 0)
493 msg->seqnum = strtoull(&key[7], NULL, 10);
494 else if (strncmp(key, "PHYSDEVPATH=", 12) == 0)
495 msg->physdevpath = &key[12];
496 else if (strncmp(key, "MAJOR=", 6) == 0)
497 major = strtoull(&key[6], NULL, 10);
498 else if (strncmp(key, "MINOR=", 6) == 0)
499 minor = strtoull(&key[6], NULL, 10);
500 else if (strncmp(key, "TIMEOUT=", 8) == 0)
501 msg->timeout = strtoull(&key[8], NULL, 10);
503 msg->devt = makedev(major, minor);
504 msg->envp[i++] = "UDEVD_EVENT=1";
508 info("DEVPATH missing, ignore message");
516 /* receive the udevd message from userspace */
517 static struct uevent_msg *get_udevd_msg(void)
519 static struct udevd_msg usend_msg;
520 struct uevent_msg *msg;
523 struct cmsghdr *cmsg;
526 char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
530 memset(&usend_msg, 0x00, sizeof(struct udevd_msg));
531 iov.iov_base = &usend_msg;
532 iov.iov_len = sizeof(struct udevd_msg);
534 memset(&smsg, 0x00, sizeof(struct msghdr));
537 smsg.msg_control = cred_msg;
538 smsg.msg_controllen = sizeof(cred_msg);
540 size = recvmsg(udevd_sock, &smsg, 0);
543 err("unable to receive udevd message: %s", strerror(errno));
546 cmsg = CMSG_FIRSTHDR(&smsg);
547 cred = (struct ucred *) CMSG_DATA(cmsg);
549 if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
550 err("no sender credentials received, message ignored");
554 if (cred->uid != 0) {
555 err("sender uid=%i, message ignored", cred->uid);
559 if (strncmp(usend_msg.magic, UDEV_MAGIC, sizeof(UDEV_MAGIC)) != 0 ) {
560 err("message magic '%s' doesn't match, ignore it", usend_msg.magic);
564 switch (usend_msg.type) {
565 case UDEVD_UEVENT_UDEVSEND:
566 case UDEVD_UEVENT_INITSEND:
567 info("udevd event message received");
568 envbuf_size = size - offsetof(struct udevd_msg, envbuf);
569 dbg("envbuf_size=%i", envbuf_size);
570 msg = get_msg_from_envbuf(usend_msg.envbuf, envbuf_size);
573 msg->type = usend_msg.type;
575 case UDEVD_STOP_EXEC_QUEUE:
576 info("udevd message (STOP_EXEC_QUEUE) received");
579 case UDEVD_START_EXEC_QUEUE:
580 info("udevd message (START_EXEC_QUEUE) received");
584 case UDEVD_SET_LOG_LEVEL:
585 intval = (int *) usend_msg.envbuf;
586 info("udevd message (SET_LOG_PRIORITY) received, udev_log_priority=%i", *intval);
587 udev_log_priority = *intval;
588 sprintf(udev_log, "UDEV_LOG=%i", udev_log_priority);
591 case UDEVD_SET_MAX_CHILDS:
592 intval = (int *) usend_msg.envbuf;
593 info("udevd message (UDEVD_SET_MAX_CHILDS) received, max_childs=%i", *intval);
594 max_childs = *intval;
596 case UDEVD_RELOAD_RULES:
597 info("udevd message (RELOAD_RULES) received");
601 dbg("unknown message type");
606 /* receive the kernel user event message and do some sanity checks */
607 static struct uevent_msg *get_netlink_msg(void)
609 struct uevent_msg *msg;
612 static char buffer[UEVENT_BUFFER_SIZE + 512];
615 size = recv(uevent_netlink_sock, &buffer, sizeof(buffer), 0);
618 err("unable to receive udevd message: %s", strerror(errno));
622 if ((size_t)size > sizeof(buffer)-1)
623 size = sizeof(buffer)-1;
625 dbg("uevent_size=%zi", size);
627 /* start of event payload */
628 bufpos = strlen(buffer)+1;
629 msg = get_msg_from_envbuf(&buffer[bufpos], size-bufpos);
632 msg->type = UDEVD_UEVENT_NETLINK;
634 /* validate message */
635 pos = strchr(buffer, '@');
637 err("invalid uevent '%s'", buffer);
643 if (msg->action == NULL) {
644 info("no ACTION in payload found, skip event '%s'", buffer);
649 if (strcmp(msg->action, buffer) != 0) {
650 err("ACTION in payload does not match uevent, skip event '%s'", buffer);
658 static void asmlinkage sig_handler(int signum)
666 /* set flag, then write to pipe if needed */
667 sigchilds_waiting = 1;
674 /* write to pipe, which will wakeup select() in our mainloop */
675 write(signal_pipe[WRITE_END], "", 1);
678 static void udev_done(int pid, int exitstatus)
680 /* find msg associated with pid and delete it */
681 struct uevent_msg *msg;
683 list_for_each_entry(msg, &running_list, node) {
684 if (msg->pid == pid) {
685 info("seq %llu, pid [%d] exit with %i, %ld seconds old", msg->seqnum, msg->pid,
686 exitstatus, time(NULL) - msg->queue_time);
687 msg->exitstatus = exitstatus;
688 msg_queue_delete(msg);
690 /* there may be events waiting with the same devpath */
697 static void reap_sigchilds(void)
703 pid = waitpid(-1, &status, WNOHANG);
706 if (WIFEXITED(status))
707 status = WEXITSTATUS(status);
710 udev_done(pid, status);
714 static int init_udevd_socket(void)
716 struct sockaddr_un saddr;
717 const int buffersize = 16 * 1024 * 1024;
719 const int feature_on = 1;
722 memset(&saddr, 0x00, sizeof(saddr));
723 saddr.sun_family = AF_LOCAL;
724 /* use abstract namespace for socket path */
725 strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
726 addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
728 udevd_sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
729 if (udevd_sock == -1) {
730 err("error getting socket: %s", strerror(errno));
734 /* set receive buffersize */
735 setsockopt(udevd_sock, SOL_SOCKET, SO_RCVBUFFORCE, &buffersize, sizeof(buffersize));
737 /* the bind takes care of ensuring only one copy running */
738 retval = bind(udevd_sock, (struct sockaddr *) &saddr, addrlen);
740 err("bind failed: %s", strerror(errno));
744 /* enable receiving of the sender credentials */
745 setsockopt(udevd_sock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on));
750 static int init_uevent_netlink_sock(void)
752 struct sockaddr_nl snl;
753 const int buffersize = 16 * 1024 * 1024;
756 memset(&snl, 0x00, sizeof(struct sockaddr_nl));
757 snl.nl_family = AF_NETLINK;
758 snl.nl_pid = getpid();
759 snl.nl_groups = 0xffffffff;
761 uevent_netlink_sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
762 if (uevent_netlink_sock == -1) {
763 err("error getting socket: %s", strerror(errno));
767 /* set receive buffersize */
768 setsockopt(uevent_netlink_sock, SOL_SOCKET, SO_RCVBUFFORCE, &buffersize, sizeof(buffersize));
770 retval = bind(uevent_netlink_sock, (struct sockaddr *) &snl, sizeof(struct sockaddr_nl));
772 err("bind failed: %s", strerror(errno));
773 close(uevent_netlink_sock);
774 uevent_netlink_sock = -1;
780 int main(int argc, char *argv[], char *envp[])
784 struct sigaction act;
792 /* redirect std fd's, if the kernel forks us, we don't have them at all */
793 fd = open("/dev/null", O_RDWR);
795 if (fd != STDIN_FILENO)
796 dup2(fd, STDIN_FILENO);
797 if (fd != STDOUT_FILENO)
798 dup2(fd, STDOUT_FILENO);
799 if (fd != STDERR_FILENO)
800 dup2(fd, STDERR_FILENO);
801 if (fd > STDERR_FILENO)
805 logging_init("udevd");
807 err("fatal, could not open /dev/null: %s", strerror(errno));
810 dbg("version %s", UDEV_VERSION);
813 err("need to be root, exit");
817 /* parse commandline options */
818 for (i = 1 ; i < argc; i++) {
820 if (strcmp(arg, "--daemon") == 0 || strcmp(arg, "-d") == 0) {
821 info("will daemonize");
824 if (strcmp(arg, "--stop-exec-queue") == 0) {
825 info("will not execute events until START_EXEC_QUEUE is received");
830 /* init sockets to receive events */
831 if (init_udevd_socket() < 0) {
832 if (errno == EADDRINUSE) {
833 err("another udevd running, exit");
836 err("error initializing udevd socket: %s", strerror(errno));
842 if (init_uevent_netlink_sock() < 0) {
843 err("uevent socket not available");
848 /* parse the rules and keep it in memory */
849 udev_rules_init(&rules, 1);
857 dbg("daemonized fork running");
860 err("fork of daemon failed: %s", strerror(errno));
864 dbg("child [%u] running, parent exits", pid);
869 /* set scheduling priority for the daemon */
870 setpriority(PRIO_PROCESS, 0, UDEVD_PRIORITY);
875 /* become session leader */
877 dbg("our session is %d", sid);
879 /* OOM_DISABLE == -17 */
880 fd = open("/proc/self/oom_adj", O_RDWR);
882 err("error disabling OOM: %s", strerror(errno));
888 /* setup signal handler pipe */
889 retval = pipe(signal_pipe);
891 err("error getting pipes: %s", strerror(errno));
894 retval = fcntl(signal_pipe[READ_END], F_SETFL, O_NONBLOCK);
896 err("error fcntl on read pipe: %s", strerror(errno));
899 retval = fcntl(signal_pipe[WRITE_END], F_SETFL, O_NONBLOCK);
901 err("error fcntl on write pipe: %s", strerror(errno));
905 /* set signal handlers */
906 memset(&act, 0x00, sizeof(struct sigaction));
907 act.sa_handler = (void (*)(int)) sig_handler;
908 sigemptyset(&act.sa_mask);
909 act.sa_flags = SA_RESTART;
910 sigaction(SIGINT, &act, NULL);
911 sigaction(SIGTERM, &act, NULL);
912 sigaction(SIGCHLD, &act, NULL);
913 sigaction(SIGHUP, &act, NULL);
915 /* watch rules directory */
916 inotify_fd = inotify_init();
918 inotify_add_watch(inotify_fd, udev_rules_filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
920 /* maximum limit of forked childs */
921 value = getenv("UDEVD_MAX_CHILDS");
923 max_childs = strtoul(value, NULL, 10);
925 max_childs = UDEVD_MAX_CHILDS;
926 info("initialize max_childs to %u", max_childs);
928 /* start to throttle forking if maximum number of _running_ childs is reached */
929 value = getenv("UDEVD_MAX_CHILDS_RUNNING");
931 max_childs_running = strtoull(value, NULL, 10);
933 max_childs_running = UDEVD_MAX_CHILDS_RUNNING;
934 info("initialize max_childs_running to %u", max_childs_running);
936 /* clear environment for forked event processes */
939 /* export log_priority , as called programs may want to follow that setting */
940 sprintf(udev_log, "UDEV_LOG=%i", udev_log_priority);
944 maxfd = UDEV_MAX(maxfd, uevent_netlink_sock);
945 maxfd = UDEV_MAX(maxfd, signal_pipe[READ_END]);
946 maxfd = UDEV_MAX(maxfd, inotify_fd);
949 struct uevent_msg *msg;
953 FD_SET(signal_pipe[READ_END], &readfds);
954 FD_SET(udevd_sock, &readfds);
955 FD_SET(uevent_netlink_sock, &readfds);
957 FD_SET(inotify_fd, &readfds);
959 fdcount = select(maxfd+1, &readfds, NULL, NULL, NULL);
962 err("error in select: %s", strerror(errno));
966 /* get user socket message */
967 if (FD_ISSET(udevd_sock, &readfds)) {
968 msg = get_udevd_msg();
970 if (msg->type == UDEVD_UEVENT_UDEVSEND && msg->seqnum != 0) {
971 info("skip non-kernel message with SEQNUM");
974 msg_queue_insert(msg);
978 /* get kernel netlink message */
979 if (FD_ISSET(uevent_netlink_sock, &readfds)) {
980 msg = get_netlink_msg();
982 msg_queue_insert(msg);
985 /* received a signal, clear our notification pipe */
986 if (FD_ISSET(signal_pipe[READ_END], &readfds)) {
989 read(signal_pipe[READ_END], &buf, sizeof(buf));
992 /* rules directory inotify watch */
993 if ((inotify_fd > 0) && FD_ISSET(inotify_fd, &readfds)) {
996 /* discard all possible events, we can just reload the config */
997 if ((ioctl(inotify_fd, FIONREAD, &nbytes) == 0) && nbytes) {
1001 buf = malloc(nbytes);
1003 err("error getting buffer for inotify, disable watching");
1007 read(inotify_fd, buf, nbytes);
1012 /* rules changed, set by inotify or a signal*/
1013 if (reload_config) {
1015 udev_rules_close(&rules);
1016 udev_rules_init(&rules, 1);
1019 /* forked child has returned */
1020 if (sigchilds_waiting) {
1021 sigchilds_waiting = 0;
1028 msg_queue_manager();
1033 udev_rules_close(&rules);
1035 if (signal_pipe[READ_END] > 0)
1036 close(signal_pipe[READ_END]);
1037 if (signal_pipe[WRITE_END] > 0)
1038 close(signal_pipe[WRITE_END]);
1044 if (uevent_netlink_sock > 0)
1045 close(uevent_netlink_sock);