]> git.ipfire.org Git - network.git/commitdiff
networkd: Tell systemd about the daemon status
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 21:18:53 +0000 (21:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 22:57:29 +0000 (22:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/main.c

index 14aafdd3cc175fe0294ff47d0630b551f88dd315..2429ff5ec5f5d14d6b37f64ffc17d173e70155ad 100644 (file)
 #                                                                             #
 #############################################################################*/
 
+#include <errno.h>
+#include <stdlib.h>
+
+#include <systemd/sd-daemon.h>
+#include <systemd/sd-event.h>
+
 int main(int argc, char** argv) {
-       return 0;
+       // XXX Drop privileges
+
+       // We are now ready to process any requests
+       sd_notify(0, "READY=1\n" "STATUS=Processing requests...");
+
+       // Run event loop
+       // XXX TODO
+
+       // Let systemd know that we are shutting down
+       sd_notify(0, "STOPPING=1\n" "STATUS=Shutting down...");
+
+       return EXIT_SUCCESS;
+
+ERROR:
+       sd_notifyf(0, "ERRNO=%i", errno);
+
+       return EXIT_FAILURE;
 }