trivial: Fix the ctrl+c SIGINT signal handling

This was broken since we started using the no-default GMainContext.
This commit is contained in:
Richard Hughes 2021-07-29 21:59:58 +01:00
parent 192083479e
commit 6f7ceb9b35
2 changed files with 22 additions and 10 deletions

View File

@ -305,6 +305,16 @@ fu_util_sigint_cb (gpointer user_data)
} }
#endif #endif
static void
fu_util_setup_signal_handlers(FuUtilPrivate *priv)
{
#ifdef HAVE_GIO_UNIX
g_autoptr(GSource) source = g_unix_signal_source_new(SIGINT);
g_source_set_callback(source, fu_util_sigint_cb, priv, NULL);
g_source_attach(g_steal_pointer(&source), priv->main_ctx);
#endif
}
static void static void
fu_util_private_free (FuUtilPrivate *priv) fu_util_private_free (FuUtilPrivate *priv)
{ {
@ -3261,11 +3271,7 @@ main (int argc, char *argv[])
/* do stuff on ctrl+c */ /* do stuff on ctrl+c */
priv->cancellable = g_cancellable_new (); priv->cancellable = g_cancellable_new ();
#ifdef HAVE_GIO_UNIX fu_util_setup_signal_handlers(priv);
g_unix_signal_add_full (G_PRIORITY_DEFAULT,
SIGINT, fu_util_sigint_cb,
priv, NULL);
#endif
g_signal_connect (priv->cancellable, "cancelled", g_signal_connect (priv->cancellable, "cancelled",
G_CALLBACK (fu_util_cancelled_cb), priv); G_CALLBACK (fu_util_cancelled_cb), priv);

View File

@ -2769,6 +2769,16 @@ fu_util_sigint_cb (gpointer user_data)
} }
#endif #endif
static void
fu_util_setup_signal_handlers(FuUtilPrivate *priv)
{
#ifdef HAVE_GIO_UNIX
g_autoptr(GSource) source = g_unix_signal_source_new(SIGINT);
g_source_set_callback(source, fu_util_sigint_cb, priv, NULL);
g_source_attach(g_steal_pointer(&source), priv->main_ctx);
#endif
}
static void static void
fu_util_private_free (FuUtilPrivate *priv) fu_util_private_free (FuUtilPrivate *priv)
{ {
@ -3383,11 +3393,7 @@ main (int argc, char *argv[])
/* do stuff on ctrl+c */ /* do stuff on ctrl+c */
priv->cancellable = g_cancellable_new (); priv->cancellable = g_cancellable_new ();
#ifdef HAVE_GIO_UNIX fu_util_setup_signal_handlers(priv);
g_unix_signal_add_full (G_PRIORITY_DEFAULT,
SIGINT, fu_util_sigint_cb,
priv, NULL);
#endif
/* sort by command name */ /* sort by command name */
fu_util_cmd_array_sort (cmd_array); fu_util_cmd_array_sort (cmd_array);