1
0
mirror of synced 2024-12-12 07:51:05 +01:00
ImHex/lib/libimhex/source/helpers/utils_linux.cpp
iTrooz ac2a609d0a
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.
2023-07-05 20:50:46 +02:00

28 lines
608 B
C++

#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