mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
impr: Use execvp() instead of system() on Linux (#1170)
This PR it just a hack to fix #1160 , it doesn't solve the underlying problem. It fixes the problem because by using execvp() directly, it avoids the call to `sh` done with `system()`, which has a bug on Ubuntu 22.04 which makes it i,compatibles with the glibc inside the AppImage. It doesn't fix the underlying problem because the programs we call themselves still link to the AppImage's libraries instead of the system ones.
This commit is contained in:
27
lib/libimhex/source/helpers/utils_linux.cpp
Normal file
27
lib/libimhex/source/helpers/utils_linux.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#if defined(OS_LINUX)
|
||||
|
||||
#include<hex/helpers/logger.hpp>
|
||||
|
||||
#include<vector>
|
||||
#include<string>
|
||||
#include<unistd.h>
|
||||
|
||||
namespace hex {
|
||||
|
||||
void executeCmd(const std::vector<std::string> &argsVector) {
|
||||
std::vector<char*> cArgsVector;
|
||||
for (const auto &str : argsVector) {
|
||||
cArgsVector.push_back(const_cast<char*>(str.c_str()));
|
||||
}
|
||||
cArgsVector.push_back(nullptr);
|
||||
|
||||
if (fork() == 0) {
|
||||
execvp(cArgsVector[0], &cArgsVector[0]);
|
||||
log::error("execvp() failed: {}", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user