summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-12-02 19:08:31 -0600
committerDenis Kenzior <denkenz@gmail.com>2009-12-02 19:11:36 -0600
commitb0f0e248e9c945239e0d6dd2ea5a37cb8227e51c (patch)
tree6328518c613504e12a80db9961ccf28db39bcced /src/main.c
parentc25532df5025f85de7a082be2f20fac1efae24e0 (diff)
downloadofono-b0f0e248e9c945239e0d6dd2ea5a37cb8227e51c.tar.bz2
When SIGTERM is received, run the event loop
This feature will continue running the event loop for another 10 seconds or so or until all the modems have been shut down. This will allow the modem drivers to properly shutdown their respective devices.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 7542e13c..3b95e159 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,7 +33,21 @@
#include "ofono.h"
+#define SHUTDOWN_GRACE_SECONDS 10
+
static GMainLoop *event_loop;
+static guint quit_eventloop_source = 0;
+
+void __ofono_exit()
+{
+ g_main_loop_quit(event_loop);
+}
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+ __ofono_exit();
+ return FALSE;
+}
static void sig_debug(int sig)
{
@@ -42,7 +56,12 @@ static void sig_debug(int sig)
static void sig_term(int sig)
{
- g_main_loop_quit(event_loop);
+ if (quit_eventloop_source != 0)
+ return;
+
+ quit_eventloop_source = g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
+ quit_eventloop, NULL);
+ __ofono_modem_shutdown();
}
static void system_bus_disconnected(DBusConnection *conn, void *user_data)