Handle log file in parent properly

This commit is contained in:
James R committed 2019-12-16 19:28:42 -08:00
1 parent f460e83846
commit 2a016332c4
3 files changed
+20 -3

No files matched your search

+1
View File
@@ -138,6 +138,7 @@
#ifdef LOGMESSAGES
extern FILE *logstream;
extern char logfilename[1024];
#endif
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
+5 -2
View File
@@ -45,6 +45,7 @@ extern int SDL_main(int argc, char *argv[]);
#ifdef LOGMESSAGES
FILE *logstream = NULL;
char logfilename[1024];
#endif
#ifndef DOXYGEN
@@ -130,10 +131,12 @@ int main(int argc, char **argv)
#ifdef LOGMESSAGES
#ifdef DEFAULTDIR
if (logdir)
logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt");
strcpy(logfilename, va("%s/"DEFAULTDIR"/log.txt",logdir));
else
#endif
logstream = fopen("./log.txt", "wt");
strcpy(logfilename, "./log.txt");
logstream = fopen(logfilename, "wt");
#endif
//I_OutputMsg("I_StartupSystem() ...\n");
+14 -1
View File
@@ -3075,6 +3075,7 @@ static void I_Fork(void)
int child;
int status;
int signum;
int c;
child = fork();
@@ -3086,7 +3087,19 @@ static void I_Fork(void)
case 0:
break;
default:
if (wait(&status) == -1)
if (logstream)
fclose(logstream);/* the child has this */
c = wait(&status);
#ifdef LOGMESSAGES
/* By the way, exit closes files. */
logstream = fopen(logfilename, "at");
#else
logstream = 0;
#endif
if (c == -1)
{
kill(child, SIGKILL);
newsignalhandler_Warn("wait()");