[pypy-commit] pypy default: Don't close stderr!!!

arigo noreply at buildbot.pypy.org
Mon Nov 16 03:43:37 EST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r80702:f321ba3efa8f
Date: 2015-11-16 09:43 +0100
http://bitbucket.org/pypy/pypy/changeset/f321ba3efa8f/

Log:	Don't close stderr!!!

diff --git a/rpython/translator/c/src/debug_print.c b/rpython/translator/c/src/debug_print.c
--- a/rpython/translator/c/src/debug_print.c
+++ b/rpython/translator/c/src/debug_print.c
@@ -102,9 +102,14 @@
 {
   if (!debug_ready)
     return -1;
+  /* The following fflush() makes sure everything is written now, which
+     is just before a fork().  So we can fork() and close the file in
+     the subprocess without ending up with the content of the buffer
+     written twice. */
+  fflush(pypy_debug_file);
+
   // note that we deliberately ignore errno, since -1 is fine
   // in case this is not a real file
-  fflush(pypy_debug_file);
   return ftell(pypy_debug_file);
 }
 
@@ -123,7 +128,8 @@
 
   if (pypy_debug_file)
     {
-      fclose(pypy_debug_file);
+      if (pypy_debug_file != stderr)
+        fclose(pypy_debug_file);
       pypy_debug_file = NULL;
       /* if PYPYLOG was set to a name with "%d" in it, it is still
          alive, and will be reopened with the new subprocess' pid as


More information about the pypy-commit mailing list