diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-12-02 19:08:31 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-12-02 19:11:36 -0600 |
commit | b0f0e248e9c945239e0d6dd2ea5a37cb8227e51c (patch) | |
tree | 6328518c613504e12a80db9961ccf28db39bcced /src/main.c | |
parent | c25532df5025f85de7a082be2f20fac1efae24e0 (diff) | |
download | ofono-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.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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) |