[sysprof] tools/sysprof-agent: handle SIGINT like we do for sysprof-cli
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] tools/sysprof-agent: handle SIGINT like we do for sysprof-cli
- Date: Mon, 1 Aug 2022 17:16:03 +0000 (UTC)
commit 1a8a9adc97117f01197713be3254eaf42c4a759d
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 1 10:15:36 2022 -0700
tools/sysprof-agent: handle SIGINT like we do for sysprof-cli
This just forces the profiler to exit, but lets subsequent ^C usage to
actually exit the program.
src/tools/sysprof-agent.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/src/tools/sysprof-agent.c b/src/tools/sysprof-agent.c
index 4e080404..b29c20f5 100644
--- a/src/tools/sysprof-agent.c
+++ b/src/tools/sysprof-agent.c
@@ -412,6 +412,20 @@ create_connection (GIOStream *stream,
return ret;
}
+static gboolean
+sigint_handler (gpointer user_data)
+{
+ SysprofProfiler *profiler = user_data;
+
+ g_assert (SYSPROF_IS_PROFILER (profiler));
+
+ g_printerr ("\n"
+ "Profiler stopped, extracting symbols and appending to capture.\n"
+ "Press ^C again to force exit.\n");
+ sysprof_profiler_stop (profiler);
+ return G_SOURCE_REMOVE;
+}
+
int
main (int argc,
char *argv[])
@@ -606,6 +620,11 @@ main (int argc,
G_CALLBACK (subprocess_finished_cb),
NULL);
+ /* SIGINT (keyboard ^C) should stop the profiler and append symbols
+ * to the SysprofCaptureWriter.
+ */
+ g_unix_signal_add (SIGINT, sigint_handler, profiler);
+
/* Start the profiler */
sysprof_profiler_start (profiler);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]