X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincd.c;h=db719839779ad86636bd4b17a455adff97fd7818;hb=28be4baae016a5a771d0d9ec6e97ef38a4fc9e46;hp=20d0e297108fba5e218fccf2127707da44605a0c;hpb=c5373d9fc0c8e3dfb6529b35bf44efe58410e0c7;p=tinc diff --git a/src/tincd.c b/src/tincd.c index 20d0e297..db719839 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -56,6 +56,8 @@ #include "version.h" #include "random.h" #include "sandbox.h" +#include "watchdog.h" +#include "fs.h" /* If nonzero, display usage information and exit. */ static bool show_help = false; @@ -414,7 +416,9 @@ static bool drop_privs(void) { return false; } -#endif +#endif // HAVE_WINDOWS + + makedirs(DIR_CACHE | DIR_HOSTS | DIR_INVITATIONS); return sandbox_enter(); } @@ -559,7 +563,9 @@ int main(int argc, char **argv) { g_argv = argv; - if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) { + const char *listen_pid = getenv("LISTEN_PID"); + + if(listen_pid && atoi(listen_pid) == getpid()) { do_detach = false; } @@ -694,8 +700,16 @@ int main2(int argc, char **argv) { try_outgoing_connections(); +#ifdef HAVE_WATCHDOG + watchdog_start(); +#endif + status = main_loop(); +#ifdef HAVE_WATCHDOG + watchdog_stop(); +#endif + /* Shutdown properly. */ end: