[gnome-builder] threading: Prevent inheriting G_MESSAGES_DEBUG by default for launchers



commit 227badb537f08d849a84e873c971a8c51644709d
Author: vanadiae <vanadiae35 gmail com>
Date:   Wed Feb 17 23:17:27 2021 +0100

    threading: Prevent inheriting G_MESSAGES_DEBUG by default for launchers
    
    Currently when either Builder is ran with G_MESSAGES_DEBUG=all, some
    process that rely on clean stdin/stdout/stderr for e.g. IPC over stdio
    don't work as expected as they'll start to spew their debug logs because
    they inherit G_MESSAGES_DEBUG too.
    
    A possible solution would to make them clear their env before-hand
    with the subprocess launcher, but that's not always doable for various
    reasons (e.g. the git daemon isn't able to run because the OS can't find
    some libraries). So a good default solution that wouldn't require
    per-launcher clearing of G_MESSAGES_DEBUG is to set it to an empty
    string by default for all subprocess launchers, to avoid encountering
    this problem again in the future.
    
    Launchers that were affected include the git client/daemon and
    flatpak-builder that had some problems with OStree and signals.
    
    Fixes #1328

 src/libide/threading/ide-subprocess-launcher.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/src/libide/threading/ide-subprocess-launcher.c b/src/libide/threading/ide-subprocess-launcher.c
index e4883d719..2010ce545 100644
--- a/src/libide/threading/ide-subprocess-launcher.c
+++ b/src/libide/threading/ide-subprocess-launcher.c
@@ -619,6 +619,12 @@ ide_subprocess_launcher_init (IdeSubprocessLauncher *self)
   g_ptr_array_add (priv->argv, NULL);
 
   priv->cwd = g_strdup (".");
+  /* Prevent inheritance of G_MESSAGES_DEBUG because it brings a lot of problems with IPC
+   * over stdout/stdin because all the debug messages would go to stdout, which means
+   * that the connection would be closed because of invalid data. If needed it can still
+   * be set back if needed, but at least it's a good default.
+   */
+  ide_subprocess_launcher_setenv (self, "G_MESSAGES_DEBUG", "", TRUE);
 }
 
 void


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