 ===================================================================
 --- coregrind/m_main.c	(revision 10880)
 +++ coregrind/m_main.c	(working copy)
-@@ -313,6 +313,48 @@
+@@ -313,6 +313,64 @@
     }
  }
  

       VG_(printf_xml)("\n");
       VG_(printf_xml)("<pid>%d</pid>\n", VG_(getpid)());
       VG_(printf_xml)("<ppid>%d</ppid>\n", VG_(getppid)());
@@ -1374,7 +1359,6 @@
    Int     need_help          = 0; // 0 = no, 1 = --help, 2 = --help-debug
    ThreadId tid_main          = VG_INVALID_THREADID;
    Bool    logging_to_fd      = False;

-         VG_(log_output_sink).fd = tmp_log_fd;
-         VG_(fcntl)(VG_(log_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
-      }
+      tmp_log_fd = move_fd_into_safe_range(tmp_log_fd, False);
    } else {
       // If they said --log-fd=-1, don't print anything.  Plausible for use in
       // regression testing suites that use client requests to count errors.
@@ -886,18 +888,7 @@
    // Finalise the output fds: and the XML fd ..
 
    if (tmp_xml_fd >= 0) {
