mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 22:50:54 +00:00
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.
This commit is contained in:
@ -412,6 +412,20 @@ create_connection (GIOStream *stream,
|
|||||||
return ret;
|
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
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
@ -606,6 +620,11 @@ main (int argc,
|
|||||||
G_CALLBACK (subprocess_finished_cb),
|
G_CALLBACK (subprocess_finished_cb),
|
||||||
NULL);
|
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 */
|
/* Start the profiler */
|
||||||
sysprof_profiler_start (profiler);
|
sysprof_profiler_start (profiler);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user