mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-25 10:38:44 +00:00
Fix GetMainExecutable. Patch by Sam Bishop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
01b2e236b5
commit
fd6437f4f9
@ -263,11 +263,9 @@ Path::GetCurrentDirectory() {
|
|||||||
/// GetMainExecutable - Return the path to the main executable, given the
|
/// GetMainExecutable - Return the path to the main executable, given the
|
||||||
/// value of argv[0] from program startup.
|
/// value of argv[0] from program startup.
|
||||||
Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
|
Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
|
||||||
#if defined(__CYGWIN__)
|
#if defined(__linux__) || defined(__CYGWIN__)
|
||||||
char exe_link[64];
|
|
||||||
snprintf(exe_link, sizeof(exe_link), "/proc/%d/exe", getpid());
|
|
||||||
char exe_path[MAXPATHLEN];
|
char exe_path[MAXPATHLEN];
|
||||||
ssize_t len = readlink(exe_link, exe_path, sizeof(exe_path));
|
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
|
||||||
if (len > 0 && len < MAXPATHLEN - 1) {
|
if (len > 0 && len < MAXPATHLEN - 1) {
|
||||||
exe_path[len] = '\0';
|
exe_path[len] = '\0';
|
||||||
return Path(std::string(exe_path));
|
return Path(std::string(exe_path));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user