diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-29 16:55:44 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-30 10:04:38 +0100 |
commit | 929d325560a206e78d1c4afba5ae3b22605ea954 (patch) | |
tree | 057694166642c53ada3deec9678af97ffd55d579 /gdk/gdkprofiler.c | |
parent | cb60c1b83d6c79244a64de84bbc4789c71b67861 (diff) | |
download | gtk+-929d325560a206e78d1c4afba5ae3b22605ea954.tar.gz |
profiler: Exit gracefully on SIGTERM
This is nice, since it lets me quickly launch a test app
and terminate it with Ctrl-C and still produce a usable
sysprof trace.
Diffstat (limited to 'gdk/gdkprofiler.c')
-rw-r--r-- | gdk/gdkprofiler.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c index 93055ac9a8..5b4e976110 100644 --- a/gdk/gdkprofiler.c +++ b/gdk/gdkprofiler.c @@ -21,6 +21,7 @@ #include "config.h" #include <sys/types.h> +#include <signal.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -38,7 +39,7 @@ static SysprofCaptureWriter *writer = NULL; static gboolean running = FALSE; static void -profiler_stop (void) +profiler_stop (int s) { if (writer) sysprof_capture_writer_unref (writer); @@ -67,7 +68,8 @@ gdk_profiler_start (int fd) if (writer) running = TRUE; - atexit (profiler_stop); + atexit (G_CALLBACK (profiler_stop)); + signal (SIGTERM, profiler_stop); } void |