X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fdaemon%2Fsysdbd.c;h=21350f308b15bc75d624baed8f99b878011caf5c;hp=2f2afa249505b79bcfc76d10169272e6b7fcef06;hb=ddb7ffc175e49abfa69c82777b88d73e1f1103fb;hpb=eb0a6f75333ec777ab3a6bb86e9b1781b394ffd4 diff --git a/src/daemon/sysdbd.c b/src/daemon/sysdbd.c index 2f2afa2..21350f3 100644 --- a/src/daemon/sysdbd.c +++ b/src/daemon/sysdbd.c @@ -32,7 +32,7 @@ #include "sysdb.h" #include "core/plugin.h" #include "core/store.h" -#include "core/error.h" +#include "utils/error.h" #include "frontend/sock.h" @@ -89,7 +89,7 @@ exit_usage(char *name, int status) "\nOptions:\n" " -C FILE the main configuration file\n" " default: "CONFIGFILE"\n" -" -d run in background (daemonize)\n" +" -D do not run in background (daemonize)\n" "\n" " -h display this help and exit\n" " -V display the version number and copyright\n" @@ -105,7 +105,7 @@ exit_version(void) printf("SysDBd version "SDB_VERSION_STRING SDB_VERSION_EXTRA", " "built "BUILD_DATE"\n" "using libsysdb version %s%s\n" - "Copyright (C) 2012 "PACKAGE_MAINTAINER"\n" + "Copyright (C) 2012-2013 "PACKAGE_MAINTAINER"\n" "\nThis is free software under the terms of the BSD license, see " "the source for\ncopying conditions. There is NO WARRANTY; not " @@ -171,6 +171,7 @@ static void * backend_handler(void __attribute__((unused)) *data) { sdb_plugin_collector_loop(&plugin_main_loop); + sdb_log(SDB_LOG_INFO, "Shutting down backend thread"); return NULL; } /* backend_handler */ @@ -178,15 +179,17 @@ int main(int argc, char **argv) { char *config_filename = NULL; - _Bool do_daemonize = 0; + _Bool do_daemonize = 1; pthread_t backend_thread; struct sigaction sa_intterm; int status; + sdb_error_set_logger(sdb_plugin_log); + while (42) { - int opt = getopt(argc, argv, "C:dhV"); + int opt = getopt(argc, argv, "C:DhV"); if (-1 == opt) break; @@ -195,8 +198,8 @@ main(int argc, char **argv) case 'C': config_filename = optarg; break; - case 'd': - do_daemonize = 1; + case 'D': + do_daemonize = 0; break; case 'h': @@ -281,6 +284,7 @@ main(int argc, char **argv) sdb_log(SDB_LOG_INFO, "Waiting for backend thread to terminate"); plugin_main_loop.do_loop = 0; + pthread_kill(backend_thread, SIGINT); pthread_join(backend_thread, NULL); sdb_fe_sock_destroy(sock); }