+ /* set signal handlers */
+ memset(&act, 0x00, sizeof(act));
+ act.sa_handler = (void (*)(int)) event_sig_handler;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction(SIGALRM, &act, NULL);
+
+ /* reset to default */
+ act.sa_handler = SIG_DFL;
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
+ sigaction(SIGCHLD, &act, NULL);
+ sigaction(SIGHUP, &act, NULL);
+
+ /* set timeout to prevent hanging processes */
+ alarm(UDEV_EVENT_TIMEOUT);
+
+ /* clear any existing udev watch on the node */
+ if (inotify_fd != -1 &&
+ major(udev_device_get_devnum(event->dev)) != 0)
+ udev_watch_clear(event->udev, event->dev);
+
+ /* apply rules, create node, symlinks */
+ err = udev_event_execute_rules(event, rules);
+
+ /* rules may change/disable the timeout */
+ if (udev_device_get_event_timeout(event->dev) >= 0)
+ alarm(udev_device_get_event_timeout(event->dev));
+
+ /* execute RUN= */
+ if (err == 0 && !event->ignore_device && udev_get_run(event->udev))
+ udev_event_execute_run(event);
+
+ /* apply/restore inotify watch */
+ if (err == 0 && event->inotify_watch && inotify_fd != -1 &&
+ major(udev_device_get_devnum(event->dev)) != 0 &&
+ strcmp(udev_device_get_action(event->dev), "remove") != 0)
+ info(event->udev, "device will be watched for changes\n");
+ udev_watch_begin(event->udev, event->dev);
+
+ info(event->udev, "seq %llu exit with %i\n", udev_device_get_seqnum(event->dev), err);