Launch wesnothd without stdout/stderr redirection on Windows

This is only effective when wesnothd is launched as a child process of
the game client when using the Host Network Game option in the menu.
This commit is contained in:
Ignacio R. Morelle 2015-07-20 22:25:20 -04:00
parent c353981e88
commit b88879537f
2 changed files with 16 additions and 0 deletions

View file

@ -31,6 +31,9 @@ Version 1.13.1+dev:
* Miscellaneous and bug fixes:
* Fixed unbound memory read in internal time formatting code with
specially-crafted input.
* Child wesnothd processes spawned by the Host Network Game option on
Windows now display console output directly instead of using stdout.txt
and stderr.txt.
Version 1.13.1:
* Security fixes:

View file

@ -77,6 +77,14 @@
#include "gui/widgets/debug.hpp"
#endif
// For wesnothd launch code.
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif // _WIN32
struct incorrect_map_format_error;
static lg::log_domain log_config("config");
@ -867,6 +875,11 @@ void game_launcher::start_wesnothd()
#else
// start wesnoth as background job
std::string command = "cmd /C start \"wesnoth server\" /B \"" + wesnothd_program + "\" -c \"" + config + "\" -t 2 -T 5";
// Make sure wesnothd's console output is visible on the console window by
// disabling SDL's stdio redirection code for this and future child
// processes. No need to bother cleaning this up because it's only
// meaningful to SDL applications during pre-main initialization.
SetEnvironmentVariableA("SDL_STDIO_REDIRECT", "0");
#endif
LOG_GENERAL << "Starting wesnothd: "<< command << "\n";
if (std::system(command.c_str()) == 0) {