]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Duplicate the stdout file handle when used for logging.
authorSadie Powell <sadie@witchery.services>
Mon, 1 Feb 2021 18:10:53 +0000 (18:10 +0000)
committerSadie Powell <sadie@witchery.services>
Mon, 1 Feb 2021 18:10:53 +0000 (18:10 +0000)
Failure to do this may result in a crash on shutdown when started
in debug mode.

src/inspircd.cpp
win/inspircd_win32wrapper.h

index ba7e08eff39187f25b96362d9f3da598b4c7a6e7..8cbb83d6fcab2b561de23cd41aacd34a10bda47a 100644 (file)
@@ -524,7 +524,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
 
        if (Config->cmdline.forcedebug)
        {
-               FileWriter* fw = new FileWriter(stdout, 1);
+               FILE* newstdout = fdopen(dup(STDOUT_FILENO), "w");
+               FileWriter* fw = new FileWriter(newstdout, 1);
                FileLogStream* fls = new FileLogStream(LOG_RAWIO, fw);
                Logs->AddLogTypes("*", fls, true);
        }
index 7366fc3361ebe009f62af2acda63a1aafb629925..368504d61f89c9669cd48a2dcc0ecf1cf9b84471 100644 (file)
@@ -102,6 +102,8 @@ typedef SSIZE_T ssize_t;
 #define popen _popen
 #define pclose _pclose
 #define getpid _getpid
+#define dup _dup
+#define fdopen _fdopen
 
 // warning: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
 // Normally, this is a huge problem, but due to our new/delete remap, we can ignore it.