Changeset 17003 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Feb 23, 2009 11:04:55 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43198
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/linux/RTProcIsRunningByName-linux.cpp
r16999 r17003 37 37 #include <iprt/dir.h> 38 38 #include <iprt/path.h> 39 #include <iprt/stream.h> 39 40 #include <iprt/param.h> 40 41 #include <iprt/assert.h> … … 66 67 { 67 68 /* 68 * Build the path to the proc execfile of this process.69 * Build the path to the proc cmdline file of this process. 69 70 */ 70 71 char *pszPath; 71 RTStrAPrintf(&pszPath, "/proc/%s/exe", DirEntry.szName); 72 /* 73 * Read the file name of the link pointing at. 74 */ 75 char szExe[RTPATH_MAX]; 76 size_t cchExe = sizeof(szExe)-1; 77 int cchLink = readlink(pszPath, szExe, cchExe); 78 if (cchLink > 0 && (size_t)cchLink <= cchExe) 72 RTStrAPrintf(&pszPath, "/proc/%s/cmdline", DirEntry.szName); 73 PRTSTREAM pStream; 74 rc = RTStrmOpen(pszPath, "r", &pStream); 75 if(RT_SUCCESS(rc)) 79 76 { 80 szExe[cchLink] = '\0'; 77 char szLine[RTPATH_MAX]; 78 /* 79 * The fist line should be the application path always. 80 */ 81 RTStrmGetLine(pStream, szLine, sizeof(szLine)); 81 82 /* 82 83 * We are interested on the file name part only. 83 84 */ 84 char *pszFilename = RTPathFilename(sz Exe);85 char *pszFilename = RTPathFilename(szLine); 85 86 if (RTStrCmp(pszFilename, pszName) == 0) 86 87 { … … 88 89 * Clean up 89 90 */ 91 RTStrmClose(pStream); 90 92 RTStrFree(pszPath); 91 93 RTDirClose(pDir); 92 94 return true; 93 95 } 96 RTStrmClose(pStream); 94 97 } 95 98 RTStrFree(pszPath);
Note:
See TracChangeset
for help on using the changeset viewer.