[glib: 1/2] gtestutils: pass open file descriptors to subprocess



commit 69a48333c2d38a6baa909271dd92c5980c9d69bb
Author: Paolo Bonzini <pbonzini redhat com>
Date:   Tue Nov 27 19:24:35 2018 +0100

    gtestutils: pass open file descriptors to subprocess
    
    The subprocess needs to access the test_log_fd.  If the file descriptors
    are not left open, functions such as g_test_message may stomp on file
    descriptors open by the subprocess and cause bad behavior of the test.
    
    (Tweaked by Philip Withnall <bugzilla tecnocode co uk> to fix review
    comments.)

 glib/gtestutils.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 046bc017b..c9bc3dd49 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -3431,6 +3431,8 @@ g_test_trap_subprocess (const char           *test_path,
   g_ptr_array_add (argv, NULL);
 
   flags = G_SPAWN_DO_NOT_REAP_CHILD;
+  if (test_log_fd != -1)
+    flags |= G_SPAWN_LEAVE_DESCRIPTORS_OPEN;
   if (test_flags & G_TEST_TRAP_INHERIT_STDIN)
     flags |= G_SPAWN_CHILD_INHERITS_STDIN;
 


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