turn off stdout, stderr of the game on linux

This commit is contained in:
Lion Kortlepel 2024-09-24 21:56:55 +02:00
parent ae9af1470c
commit 95436cb073
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -100,7 +100,11 @@ void StartGame(std::string Dir) {
std::string filename = (Dir + "/BinLinux/BeamNG.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 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, argv, environ);
if (result != 0) {
error("Failed to Launch the game! launcher closing soon");