From c39cf46776ae6c8f89aec0d35e6fc08f65255667 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 11 Feb 2020 18:39:20 -0800 Subject: [PATCH] tools: perform cleanup/supplementals when stopping profiler --- src/tools/sysprof-cli.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/tools/sysprof-cli.c b/src/tools/sysprof-cli.c index 72b94e74..78296b39 100644 --- a/src/tools/sysprof-cli.c +++ b/src/tools/sysprof-cli.c @@ -44,15 +44,33 @@ static int exit_code = EXIT_SUCCESS; static gboolean sigint_handler (gpointer user_data) { - g_main_loop_quit (main_loop); - return G_SOURCE_REMOVE; + static int count; + + if (count >= 2) + { + g_main_loop_quit (main_loop); + return G_SOURCE_REMOVE; + } + + g_printerr ("\n"); + + if (count == 0) + { + g_printerr ("%s\n", _("Stopping profiler. Press twice more ^C to force exit.")); + sysprof_profiler_stop (profiler); + } + + count++; + + return G_SOURCE_CONTINUE; } static void profiler_stopped (SysprofProfiler *profiler_, GMainLoop *main_loop_) { - g_main_loop_quit (main_loop_); + g_printerr ("%s\n", _("Profiler stopped.")); + g_main_loop_quit (main_loop); } static void