Add support for systemd style socket activation.

If the LISTEN_FDS environment variable is set and tinc is run in the
foreground, tinc will use filedescriptors 3 to 3 + LISTEN_FDS for its listening
TCP sockets. For now, tinc will create matching listening UDP sockets itself.

There is no dependency on systemd or on libsystemd-daemon.
This commit is contained in:
Guus Sliepen 2012-03-26 14:46:09 +01:00
parent cc6aee7846
commit 89f4574e0b
2 changed files with 94 additions and 47 deletions

View file

@ -539,6 +539,12 @@ int main(int argc, char **argv) {
g_argv = argv;
if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid())
do_detach = false;
#ifdef HAVE_UNSETENV
unsetenv("LISTEN_PID");
#endif
init_configuration(&config_tree);
/* Slllluuuuuuurrrrp! */