mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 21:01:04 +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
|
#ifdef LOGMESSAGES
|
||||||
extern FILE *logstream;
|
extern FILE *logstream;
|
||||||
|
extern char logfilename[1024];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
|
//#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
|
#ifdef LOGMESSAGES
|
||||||
FILE *logstream = NULL;
|
FILE *logstream = NULL;
|
||||||
|
char logfilename[1024];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DOXYGEN
|
#ifndef DOXYGEN
|
||||||
|
@ -130,10 +131,12 @@ int main(int argc, char **argv)
|
||||||
#ifdef LOGMESSAGES
|
#ifdef LOGMESSAGES
|
||||||
#ifdef DEFAULTDIR
|
#ifdef DEFAULTDIR
|
||||||
if (logdir)
|
if (logdir)
|
||||||
logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt");
|
strcpy(logfilename, va("%s/"DEFAULTDIR"/log.txt",logdir));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
logstream = fopen("./log.txt", "wt");
|
strcpy(logfilename, "./log.txt");
|
||||||
|
|
||||||
|
logstream = fopen(logfilename, "wt");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//I_OutputMsg("I_StartupSystem() ...\n");
|
//I_OutputMsg("I_StartupSystem() ...\n");
|
||||||
|
|
|
@ -3075,6 +3075,7 @@ static void I_Fork(void)
|
||||||
int child;
|
int child;
|
||||||
int status;
|
int status;
|
||||||
int signum;
|
int signum;
|
||||||
|
int c;
|
||||||
|
|
||||||
child = fork();
|
child = fork();
|
||||||
|
|
||||||
|
@ -3086,7 +3087,19 @@ static void I_Fork(void)
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
kill(child, SIGKILL);
|
||||||
newsignalhandler_Warn("wait()");
|
newsignalhandler_Warn("wait()");
|
||||||
|
|
Loading…
Reference in a new issue