diff options
author | Seo Sanghyeon <sanxiyn@gmail.com> | 2008-06-27 22:55:30 +0000 |
---|---|---|
committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2008-06-27 22:55:30 +0000 |
commit | fd6437f4f929dd7aa5304cc844478d1866f988c2 (patch) | |
tree | c5f9f4a32aeffb15e747b014ccf776a3d0845c74 /lib/System/Unix/Path.inc | |
parent | 01b2e236b571e7c22ee8493b7ea19eda9830d75c (diff) | |
download | llvm-fd6437f4f929dd7aa5304cc844478d1866f988c2.tar.gz llvm-fd6437f4f929dd7aa5304cc844478d1866f988c2.tar.bz2 llvm-fd6437f4f929dd7aa5304cc844478d1866f988c2.tar.xz |
Fix GetMainExecutable. Patch by Sam Bishop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Path.inc')
-rw-r--r-- | lib/System/Unix/Path.inc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 20d09c0f7f..1de594b866 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -263,11 +263,9 @@ Path::GetCurrentDirectory() { /// GetMainExecutable - Return the path to the main executable, given the /// value of argv[0] from program startup. Path Path::GetMainExecutable(const char *argv0, void *MainAddr) { -#if defined(__CYGWIN__) - char exe_link[64]; - snprintf(exe_link, sizeof(exe_link), "/proc/%d/exe", getpid()); +#if defined(__linux__) || defined(__CYGWIN__) 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) { exe_path[len] = '\0'; return Path(std::string(exe_path)); |