From 1dc653f8f3bdf98cec4ef7c72c95e58a472521cc Mon Sep 17 00:00:00 2001 From: "Gu://em_" Date: Fri, 21 Nov 2025 20:54:38 +0100 Subject: [PATCH] feat: new daemon module with daemon_restart and daemon_stop implementations + daemon_start prototype --- httpd/src/daemon/daemon.c | 21 +++++++++++++++++++++ httpd/src/daemon/daemon.h | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 httpd/src/daemon/daemon.c create mode 100644 httpd/src/daemon/daemon.h diff --git a/httpd/src/daemon/daemon.c b/httpd/src/daemon/daemon.c new file mode 100644 index 0000000..3962703 --- /dev/null +++ b/httpd/src/daemon/daemon.c @@ -0,0 +1,21 @@ +#include "daemon.h" + +#include + +void stop_daemon(int pid) +{ + if (pid != -1) + kill(pid, SIGINT); +} + +int start_daemon(void) +{} + +int restart_daemon(int pid) +{ + // Attempt to kill process + stop_daemon(pid); + + // Start again + return start_daemon(); +} diff --git a/httpd/src/daemon/daemon.h b/httpd/src/daemon/daemon.h new file mode 100644 index 0000000..f83ec6a --- /dev/null +++ b/httpd/src/daemon/daemon.h @@ -0,0 +1,26 @@ +#ifndef DAEMON_H +#define DAEMON_H + +#include "../config/config.h" + +/* @brief + * + * @param + */ +void stop_daemon(int pid); + +/* @brief + * + * @param + */ +int start_daemon(void); + +/* @brief + * + * @param + * + * @return + */ +int restart_daemon(int pid); + +#endif // ! DAEMON_H