mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Handle log file in parent properly
This commit is contained in:
parent
f460e83846
commit
2a016332c4
3 changed files with 20 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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()");
|
||||
|
|
Loading…
Reference in a new issue