[llvm-commits] [llvm] r52847 - /llvm/trunk/lib/System/Unix/Path.inc
    Seo Sanghyeon 
    sanxiyn at gmail.com
       
    Fri Jun 27 15:55:30 PDT 2008
    
    
  
Author: sanxiyn
Date: Fri Jun 27 17:55:30 2008
New Revision: 52847
URL: http://llvm.org/viewvc/llvm-project?rev=52847&view=rev
Log:
Fix GetMainExecutable. Patch by Sam Bishop.
Modified:
    llvm/trunk/lib/System/Unix/Path.inc
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=52847&r1=52846&r2=52847&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Fri Jun 27 17:55:30 2008
@@ -263,11 +263,9 @@
 /// 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));
    
    
More information about the llvm-commits
mailing list