diff --git a/src/GameStart.cpp b/src/GameStart.cpp index ac99d63..a3749fa 100644 --- a/src/GameStart.cpp +++ b/src/GameStart.cpp @@ -10,6 +10,8 @@ #include #elif defined(__linux__) #include "vdf_parser.hpp" +#include +#include #include #include #include @@ -90,11 +92,27 @@ void StartGame(std::string Dir) { } #elif defined(__linux__) void StartGame(std::string Dir) { - int status; std::string filename = (Dir + "/BinLinux/BeamNG.drive.x64"); char* argv[] = { filename.data(), NULL }; pid_t pid; - int result = posix_spawn(&pid, filename.c_str(), NULL, NULL, argv, environ); + + posix_spawn_file_actions_t file_actions; + auto status = posix_spawn_file_actions_init(&file_actions); + // disable stdout + if (status != 0) { + error(std::string("posix_spawn_file_actions_init failed: ") + std::strerror(errno)); + } + status = posix_spawn_file_actions_addclose(&file_actions, STDOUT_FILENO); + if (status != 0) { + error(std::string("posix_spawn_file_actions_addclose for STDOUT failed: ") + std::strerror(errno)); + } + status = posix_spawn_file_actions_addclose(&file_actions, STDERR_FILENO); + if (status != 0) { + error(std::string("posix_spawn_file_actions_addclose for STDERR failed: ") + std::strerror(errno)); + } + + // launch the game + int result = posix_spawn(&pid, filename.c_str(), &file_actions, NULL, argv, environ); if (result != 0) { error("Failed to Launch the game! launcher closing soon");