Changeset 17018 in vbox
- Timestamp:
- Feb 23, 2009 1:27:43 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43218
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/process.h
r16999 r17018 249 249 250 250 /** 251 * Check if the given process is running on the system. This check is case 252 * sensitive. 251 * Check if the given process is running on the system. 252 * 253 * This check is case sensitive on most systems, except for Windows, OS/2 and 254 * Darwin. 253 255 * 254 256 * @returns true if the process is running & false otherwise. 255 * @param pszName Process name to search for. 257 * @param pszName Process name to search for. If no path is given only the 258 * filename part of the running process set will be 259 * matched. If a path is specified, the full path will be 260 * matched. 256 261 */ 257 262 RTR3DECL(bool) RTProcIsRunningByName(const char *pszName); -
trunk/src/VBox/Runtime/r3/linux/RTProcIsRunningByName-linux.cpp
r17016 r17018 52 52 return false; 53 53 54 bool fFoundIt = false; 54 bool const fWithPath = RTPathHavePath(pszName); 55 56 /* 57 * Enumerate /proc. 58 */ 55 59 PRTDIR pDir; 56 60 int rc = RTDirOpen(&pDir, "/proc"); … … 99 103 * We are interested on the file name part only. 100 104 */ 101 char const *psz Filename =RTPathFilename(szExe);102 if (RTStrCmp(psz Filename, pszName) == 0)105 char const *pszProcName = fWithPath ? szExe : RTPathFilename(szExe); 106 if (RTStrCmp(pszProcName, pszName) == 0) 103 107 { 104 108 /* Found it! */ -
trunk/src/VBox/Runtime/testcase/tstRTProcIsRunningByName.cpp
r17011 r17018 38 38 #include <iprt/param.h> 39 39 #include <iprt/path.h> 40 #include <iprt/string.h> 40 41 41 42 … … 51 52 * Test 1: Check for a definitely not running process. 52 53 */ 53 int rc = VERR_GENERAL_FAILURE;54 54 char szExecPath[RTPATH_MAX] = { "vbox-5b05e1ff-6ae2-4d10-885a-7d25018c4c5b" }; 55 bool fRunning = RTProcIsRunningByName(szExecPath); 56 if (!fRunning) 55 if (!RTProcIsRunningByName(szExecPath)) 57 56 RTPrintf("tstRTProcIsRunningByName: Process '%s' is not running (expected).\n", szExecPath); 58 57 else … … 63 62 64 63 /* 65 * Test 2: Check for our own process. 64 * Test 2: Check for a definitely not running process. 65 */ 66 strcpy(szExecPath, "/bin/vbox-5b05e1ff-6ae2-4d10-885a-7d25018c4c5b"); 67 if (!RTProcIsRunningByName(szExecPath)) 68 RTPrintf("tstRTProcIsRunningByName: Process '%s' is not running (expected).\n", szExecPath); 69 else 70 { 71 RTPrintf("tstRTProcIsRunningByName: FAILURE - '%s' is running! (test 1)\n", szExecPath); 72 cErrors++; 73 } 74 75 /* 76 * Test 3: Check for our own process, filename only. 66 77 */ 67 78 if (RTProcGetExecutableName(szExecPath, RTPATH_MAX)) … … 71 82 if (pszFilename) 72 83 { 73 bool fRunning = RTProcIsRunningByName(pszFilename); 74 if (fRunning) 84 if (RTProcIsRunningByName(pszFilename)) 75 85 RTPrintf("tstRTProcIsRunningByName: Process '%s' (self) is running\n", pszFilename); 76 86 else … … 85 95 cErrors++; 86 96 } 97 98 /* 99 * Test 4: Check for our own process, full path. 100 */ 101 if (RTProcIsRunningByName(szExecPath)) 102 RTPrintf("tstRTProcIsRunningByName: Process '%s' (self) is running\n", szExecPath); 103 else 104 { 105 RTPrintf("tstRTProcIsRunningByName: FAILURE - Process '%s' (self) is not running!\n", szExecPath); 106 cErrors++; 107 } 87 108 } 88 109 else … … 91 112 cErrors++; 92 113 } 114 93 115 94 116 /*
Note:
See TracChangeset
for help on using the changeset viewer.