[tracker-miners/wip/carlosg/writeback-coverage] tracker-writeback: Exit cleanly on SIGTERM




commit 9df66a5c25bbc5d75ad3c47963b82624407bc1ec
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Sep 26 13:05:45 2022 +0200

    tracker-writeback: Exit cleanly on SIGTERM
    
    "Increase coverage with this weird trick", quit the main loop when
    SIGTERM is received, so that the writeback process can exit cleanly,
    and its coverage information ends up written.
    
    Should fix the 0% coverage seen in src/tracker-writeback altogether,
    since we do have functional tests that exercise this code.

 src/tracker-writeback/tracker-main.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/tracker-writeback/tracker-main.c b/src/tracker-writeback/tracker-main.c
index 2eddd5be1..972427429 100644
--- a/src/tracker-writeback/tracker-main.c
+++ b/src/tracker-writeback/tracker-main.c
@@ -24,6 +24,8 @@
 
 #include <glib/gi18n.h>
 
+#include <glib-unix.h>
+
 #include "tracker-writeback.h"
 
 #define ABOUT    \
@@ -61,6 +63,12 @@ static GOptionEntry  entries[] = {
        { NULL }
 };
 
+static gboolean
+on_sigterm (gpointer user_data)
+{
+       g_main_loop_quit (user_data);
+       return G_SOURCE_REMOVE;
+}
 
 int
 main (int   argc,
@@ -110,6 +118,7 @@ main (int   argc,
        g_message ("Main thread is: %p", g_thread_self ());
 
        loop = g_main_loop_new (NULL, FALSE);
+       g_unix_signal_add (SIGTERM, on_sigterm, loop);
        g_main_loop_run (loop);
 
        g_object_unref (controller);


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