diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-09 22:12:19 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-03-09 22:12:19 +0000 | 
| commit | e7e20e6343bd6b8c9b3100e66a612900ab94caff (patch) | |
| tree | 8da255fb59d6dbddd5a2cdbb6d75822d85038428 | |
| parent | f612aabb413e813f8800ff85f341e994885a5692 (diff) | |
Network: main loop creation
| -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;  } | 
