summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/main.c b/main.c
index bcf52d8..90eaf85 100644
--- a/main.c
+++ b/main.c
@@ -4,6 +4,15 @@
#include <glib.h>
#include <glib-object.h>
+#include <signal.h>
+
+GMainLoop *main_loop;
+
+static void sig_handler(int sig) {
+ g_debug("caught signal %d", sig);
+ g_main_loop_quit(main_loop);
+}
+
int main(int argc, char **argv) {
g_type_init();
@@ -12,8 +21,14 @@ int main(int argc, char **argv) {
httpd_start();
- GMainLoop *main_loop = g_main_loop_new(NULL, FALSE);
+ signal(SIGINT, sig_handler);
+
+ main_loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(main_loop);
+ while(g_main_loop_is_running(main_loop) == TRUE) {
+ g_debug("main loop still running");
+ }
+ g_main_loop_unref(main_loop);
httpd_stop();
music_free();