[gtk/builder-precompile] profiler: Exit gracefully on SIGTERM



commit 5c999f98cf284b5b54b1b5631850b34f49bbb8ee
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 29 16:55:44 2020 +0100

    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.

 gdk/gdkprofiler.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c
index 93055ac9a8..bde1a10bdc 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);
@@ -68,6 +69,7 @@ gdk_profiler_start (int fd)
     running = TRUE;
 
   atexit (profiler_stop);
+  signal (SIGTERM, profiler_stop);
 }
 
 void


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