Add a new flag, --child-silent-after-fork=no|yes [no].  When enabled,
causes child processes after fork to fall completely silent, which can
make the output a lot less confusing.  In addition it is pretty much
essential in XML output mode, so as to avoid mixing up any child XML
output with the parent's.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7177 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c
index a5129ef..5ba8bb1 100644
--- a/coregrind/m_libcprint.c
+++ b/coregrind/m_libcprint.c
@@ -53,7 +53,12 @@
 static void send_bytes_to_logging_sink ( Char* msg, Int nbytes )
 {
    if (!VG_(logging_to_socket)) {
-      VG_(write)( VG_(clo_log_fd), msg, nbytes );
+      /* VG_(clo_log_fd) could have been set to -1 in the various
+         sys-wrappers for sys_fork, if --child-silent-after-fork=yes
+         is in effect.  That is a signal that we should not produce
+         any more output. */
+      if (VG_(clo_log_fd) >= 0)
+         VG_(write)( VG_(clo_log_fd), msg, nbytes );
    } else {
       Int rc = VG_(write_socket)( VG_(clo_log_fd), msg, nbytes );
       if (rc == -1) {