Page 1 of 1

stdio buffering leaves stderr.txt truncated in a crash

Posted: Sun Jul 13, 2014 5:18 am
by filbo
setbuf() should be compatible with all RnD port targets.

Code: Select all

--- src/libgame/misc.c.orig	2013-11-22 11:04:23.000000000 -0800
+++ src/libgame/misc.c	2014-07-12 22:22:19.000000000 -0700
@@ -3107,6 +3107,11 @@
   if ((program.error_file = fopen(program.error_filename, MODE_WRITE)) == NULL)
     fprintf_newline(stderr, "ERROR: cannot open file '%s' for writing!",
 		    program.error_filename);
+  else
+  {
+    /* stderr should be unbuffered so it is not truncated in a crash */
+    setbuf(program.error_file, NULL);
+  }
 }
 
 void closeErrorFile()

Re: stdio buffering leaves stderr.txt truncated in a crash

Posted: Wed Sep 17, 2014 7:28 pm
by Holger
This fix is already incorporated into the current development version of R'n'D, available from the Git repository!

Thanks a lot for this addition! :-)