[sysprof] tools: perform cleanup/supplementals when stopping profiler



commit c39cf46776ae6c8f89aec0d35e6fc08f65255667
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 11 18:39:20 2020 -0800

    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 72b94e7..78296b3 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]