summaryrefslogtreecommitdiff
path: root/src/daemon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon.h')
-rw-r--r--src/daemon.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/daemon.h b/src/daemon.h
new file mode 100644
index 0000000..b992ab3
--- /dev/null
+++ b/src/daemon.h
@@ -0,0 +1,27 @@
+#ifndef UMBRELLA_DAEMON_H
+#define UMBRELLA_DAEMON_H
+
+/*
+ * daemon_init: set up signal handling, pid file, and socket directory.
+ * Returns 0 on success, -1 on error.
+ */
+int daemon_init(void);
+
+/*
+ * daemon_daemonize: fork into background, detach from terminal.
+ * Call before daemon_init if running as a true background daemon.
+ * Pass 0 to run in foreground (useful for debugging/systemd).
+ */
+int daemon_daemonize(int foreground);
+
+/*
+ * daemon_cleanup: remove pid file and socket on exit.
+ */
+void daemon_cleanup(void);
+
+/*
+ * daemon_write_pid: write our pid to UMBRELLA_PID_FILE.
+ */
+int daemon_write_pid(void);
+
+#endif /* UMBRELLA_DAEMON_H */