mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
print posix_spawn errors
This commit is contained in:
parent
9ebd218856
commit
453b6b0e1b
@ -6,6 +6,7 @@
|
||||
/// Created by Anonymous275 on 7/19/2020
|
||||
///
|
||||
|
||||
#include <cstring>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
@ -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<const char*> 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<char**>(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<char**>(argv.data()), environ);
|
||||
|
||||
if (result != 0) {
|
||||
error("Failed to Launch the game! launcher closing soon");
|
||||
|
Loading…
x
Reference in New Issue
Block a user