forked from WerWolv/ImHex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impr: Use execvp() instead of system() on Linux (WerWolv#1170)
This PR it just a hack to fix WerWolv#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.
- Loading branch information
Showing
6 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#if defined(OS_LINUX) | ||
|
||
namespace hex { | ||
void executeCmd(const std::vector<std::string> &argsVector); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters