From: Matthias Clasen Date: Wed, 29 Jan 2020 15:55:44 +0000 (+0100) Subject: profiler: Exit gracefully on SIGTERM X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~127 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=929d325560a206e78d1c4afba5ae3b22605ea954;p=gtk4.git 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. --- 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 +#include #ifdef HAVE_UNISTD_H #include @@ -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