diff options
| -rw-r--r-- | network/main.c | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/network/main.c b/network/main.c index e51c73aa..776ea517 100644 --- a/network/main.c +++ b/network/main.c @@ -26,15 +26,57 @@  #endif  #include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h>  #include <errno.h> +#include <signal.h> +#include <glib.h> + +#include "dbus.h" +#include "logging.h"  #include "manager.h" +static GMainLoop *main_loop; + +static void sig_term(int sig) +{ +	g_main_loop_quit(main_loop); +} +  int main(int argc, char *argv[])  { +	struct sigaction sa; + +	start_logging("network", "Bluetooth Network daemon"); + +	memset(&sa, 0, sizeof(sa)); +	sa.sa_flags = SA_NOCLDSTOP; +	sa.sa_handler = sig_term; +	sigaction(SIGTERM, &sa, NULL); +	sigaction(SIGINT,  &sa, NULL); + +	sa.sa_handler = SIG_IGN; +	sigaction(SIGCHLD, &sa, NULL); +	sigaction(SIGPIPE, &sa, NULL); + +	enable_debug(); + +	/* Create event loop */ +	main_loop = g_main_loop_new(NULL, FALSE); +  	network_init(); +	g_main_loop_run(main_loop); +  	network_exit(); +	g_main_loop_unref(main_loop); + +	info("Exit"); + +	stop_logging(); +  	return 0;  } | 
