summaryrefslogtreecommitdiff
path: root/src/miavd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/miavd.cc')
-rw-r--r--src/miavd.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/miavd.cc b/src/miavd.cc
index e9d7bc4..4ff3425 100644
--- a/src/miavd.cc
+++ b/src/miavd.cc
@@ -32,6 +32,9 @@
#include <config.h>
+// For signal
+#include <signal.h>
+
#include "miav_daemon.h"
#include "miav_config.h"
@@ -62,6 +65,23 @@ static const char usage_str[] =
" -P, --pidfile file Write pid of the running daemon to file.\n"
;
+bool server_is_running = true;
+void ctrl_c(int)
+{
+ DEBUG(server, "Ctrl+c detected");
+ server_is_running = false;
+}
+
+void reload(int)
+{
+ printf("Reopening logfile...\n");
+ if(hugin_reopen_log() != HUG_STATUS_OK) {
+ fprintf(stderr, "Could not reopen logfile!\n");
+ return;
+ }
+ DEBUG(server, "Reopened log\n");
+}
+
int main(int argc, char *argv[])
{
const char *hugin_filter = "+all";
@@ -168,5 +188,8 @@ int main(int argc, char *argv[])
if(user) cuser = user;
if(group) cgroup = group;
+ signal(SIGHUP, reload);
+ signal(SIGINT, ctrl_c);
+
return daemon.run(cuser, cgroup, !foreground, pidfile);
}