diff --git a/src/GameStart.cpp b/src/GameStart.cpp index 194d13b..ad4b317 100644 --- a/src/GameStart.cpp +++ b/src/GameStart.cpp @@ -6,6 +6,7 @@ /// Created by Anonymous275 on 7/19/2020 /// +#include #if defined(_WIN32) #include #include @@ -105,7 +106,6 @@ void StartGame(std::string Dir) { } #elif defined(__linux__) void StartGame(std::string Dir) { - int status; std::string filename = (Dir + "/BinLinux/BeamNG.drive.x64"); std::vector argv; argv.push_back(filename.data()); @@ -115,11 +115,24 @@ void StartGame(std::string Dir) { argv.push_back(nullptr); pid_t pid; - posix_spawn_file_actions_t spawn_actions; - posix_spawn_file_actions_init(&spawn_actions); - posix_spawn_file_actions_addclose(&spawn_actions, STDOUT_FILENO); - posix_spawn_file_actions_addclose(&spawn_actions, STDERR_FILENO); - int result = posix_spawn(&pid, filename.c_str(), &spawn_actions, nullptr, const_cast(argv.data()), 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, const_cast(argv.data()), environ); if (result != 0) { error("Failed to Launch the game! launcher closing soon");