diff options
Diffstat (limited to 'src/daemon/main.c')
-rw-r--r-- | src/daemon/main.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c new file mode 100644 index 0000000..9ecdd4d --- /dev/null +++ b/src/daemon/main.c @@ -0,0 +1,45 @@ +/* + * Usurpation – server daemon main logic + * + * Copyright (C) 2019 Gediminas Jakutis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <unistd.h> +#include <time.h> +#include <stdio.h> +#include "settings.h" + +/* the logic is a placeholder right now */ +int main(int argc, char **argv) +{ + extern const char * const version; + struct timespec t = {3600, 0}; /* one hour */ + + printf("Usurpation daemon version %s starting\n", version); + + /* by default and if running by as a system service, the init system + * needs to keep control of the process and thus only detach if + * requested when ran manually by a user. + */ + if (setting_detach()) { + daemon(0, 0); + } + + while(!(nanosleep(&t, NULL))) { + /* noop */ + } +} |