+static void reload_cb(struct uloop_fd *u, _unused unsigned int events)
+{
+ char b[512];
+ if (read(u->fd, b, sizeof(b)) < 0) {}
+ odhcpd_reload();
+}
+
+static struct uloop_fd reload_fd = { .cb = reload_cb };
+
+void odhcpd_run(void)
+{
+ if (pipe2(reload_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {}
+ reload_fd.fd = reload_pipe[0];
+ uloop_fd_add(&reload_fd, ULOOP_READ);
+
+ signal(SIGTERM, handle_signal);
+ signal(SIGINT, handle_signal);
+ signal(SIGHUP, handle_signal);
+
+#ifdef WITH_UBUS
+ while (init_ubus())
+ sleep(1);
+#endif
+
+ odhcpd_reload();
+ uloop_run();
+
+ while (!list_empty(&interfaces))
+ close_interface(list_first_entry(&interfaces, struct interface, head));