#include <glib-object.h>
#include <gio/gio.h>
+#include <glib-unix.h>
#include <common/watchdog-client.h>
-static void boot_manager_application_finalize (GObject *object);
-static void boot_manager_application_constructed (GObject *object);
-static void boot_manager_application_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void boot_manager_application_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void boot_manager_application_startup (GApplication *application);
+static void boot_manager_application_finalize (GObject *object);
+static void boot_manager_application_constructed (GObject *object);
+static void boot_manager_application_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void boot_manager_application_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void boot_manager_application_startup (GApplication *application);
+static gboolean boot_manager_application_int_handler (GApplication *application);
/* LUC starter to restore the LUC */
LUCHandler *luc_handler;
LUCStarter *luc_starter;
+
+ /* signal handler IDs */
+ guint sigint_id;
};
{
/* update systemd's watchdog timestamp every 120 seconds */
application->watchdog_client = watchdog_client_new (120);
+
+ /* install the signal handler */
+ application->sigint_id =
+ g_unix_signal_add (SIGINT, (GSourceFunc) boot_manager_application_int_handler,
+ application);
}
{
BootManagerApplication *application = BOOT_MANAGER_APPLICATION (object);
+ /* release the signal handler */
+ g_source_remove (application->sigint_id);
+
/* release the watchdog client */
g_object_unref (application->watchdog_client);
+static gboolean
+boot_manager_application_int_handler (GApplication *app)
+{
+ BootManagerApplication *application = BOOT_MANAGER_APPLICATION (app);
+
+ luc_starter_cancel (application->luc_starter);
+
+ return TRUE;
+}
+
+
+
BootManagerApplication *
boot_manager_application_new (BootManagerService *boot_manager,
LUCHandler *luc_handler)
const gchar *result,
GError *error,
gpointer user_data);
+static void luc_starter_cancel_start (const gchar *app,
+ GCancellable *cancellable,
+ gpointer user_data);
g_debug ("start app '%s' finish", unit);
+ /* respond to errors */
+ if (error != NULL)
+ g_warning ("start app had error: %s", error->message);
+
/* get the current start group */
group_name = starter->start_order->data;
+static void
+luc_starter_cancel_start (const gchar *app,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ g_cancellable_cancel (cancellable);
+}
+
+
+
LUCStarter *
luc_starter_new (BootManagerService *boot_manager,
LUCHandler *luc_handler)
if (starter->start_order != NULL)
luc_starter_start_next_group (starter);
}
+
+void
+luc_starter_cancel (LUCStarter *starter)
+{
+ g_hash_table_foreach (starter->cancellables, (GHFunc) luc_starter_cancel_start, NULL);
+}