diff --git a/contrib/systemd-updates/pk-offline-update.c b/contrib/systemd-updates/pk-offline-update.c index 47871e348..65bd7ec81 100644 --- a/contrib/systemd-updates/pk-offline-update.c +++ b/contrib/systemd-updates/pk-offline-update.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include @@ -526,6 +527,18 @@ pk_offline_update_loop_quit_cb (gpointer user_data) return FALSE; } +/** + * pk_offline_update_sigint_cb: + **/ +static gboolean +pk_offline_update_sigint_cb (gpointer user_data) +{ + PkOfflineUpdateHelper *helper = (PkOfflineUpdateHelper *) user_data; + pk_log_warning (helper, "Handling SIGINT"); + pk_log_write (helper); + return FALSE; +} + /** * main: **/ @@ -562,6 +575,13 @@ main (int argc, char *argv[]) helper->log = g_string_new ("started\n"); helper->time_started = g_get_real_time (); + /* do stuff on ctrl-c */ + g_unix_signal_add_full (G_PRIORITY_DEFAULT, + SIGINT, + pk_offline_update_sigint_cb, + helper, + NULL); + /* get the list of packages to update */ ret = g_file_get_contents (PK_OFFLINE_PREPARED_UPDATE_FILENAME, &packages_data,