Changeset 40571 in vbox for trunk/src/VBox/Runtime/r3/posix
- Timestamp:
- Mar 21, 2012 9:54:31 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76966
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/process-creation-posix.cpp
r40046 r40571 69 69 #include <iprt/err.h> 70 70 #include <iprt/file.h> 71 #include <iprt/path.h> 71 72 #include <iprt/pipe.h> 72 73 #include <iprt/socket.h> … … 256 257 257 258 259 /** 260 * RTPathTraverseList callback used by RTProcCreateEx to locate the executable. 261 */ 262 static DECLCALLBACK(int) rtPathFindExec(char const *pchPath, size_t cchPath, void *pvUser1, void *pvUser2) 263 { 264 const char *pszExec = (const char *)pvUser1; 265 char *pszRealExec = (char *)pvUser2; 266 int rc = RTPathJoinEx(pszRealExec, RTPATH_MAX, pchPath, cchPath, pszExec, RTSTR_MAX); 267 if (RT_FAILURE(rc)) 268 return rc; 269 if (!access(pszRealExec, X_OK)) 270 return VINF_SUCCESS; 271 if ( errno == EACCES 272 || errno == EPERM) 273 return RTErrConvertFromErrno(errno); 274 return VINF_TRY_AGAIN; 275 } 276 277 258 278 RTR3DECL(int) RTProcCreateEx(const char *pszExec, const char * const *papszArgs, RTENV hEnv, uint32_t fFlags, 259 279 PCRTHANDLE phStdIn, PCRTHANDLE phStdOut, PCRTHANDLE phStdErr, const char *pszAsUser, … … 267 287 AssertPtrReturn(pszExec, VERR_INVALID_POINTER); 268 288 AssertReturn(*pszExec, VERR_INVALID_PARAMETER); 269 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_HIDDEN | RTPROC_FLAGS_SERVICE | RTPROC_FLAGS_SAME_CONTRACT | RTPROC_FLAGS_NO_PROFILE )), VERR_INVALID_PARAMETER);289 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_HIDDEN | RTPROC_FLAGS_SERVICE | RTPROC_FLAGS_SAME_CONTRACT | RTPROC_FLAGS_NO_PROFILE | RTPROC_FLAGS_SEARCH_PATH)), VERR_INVALID_PARAMETER); 270 290 AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER); 271 291 AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER); … … 340 360 * Check for execute access to the file. 341 361 */ 362 char szRealExec[RTPATH_MAX]; 342 363 if (access(pszExec, X_OK)) 343 return RTErrConvertFromErrno(errno); 364 { 365 if ( !(fFlags & RTPROC_FLAGS_SEARCH_PATH) 366 || errno != ENOENT 367 || RTPathHavePath(pszExec) ) 368 return RTErrConvertFromErrno(errno); 369 370 /* search */ 371 char *pszPath = RTEnvDupEx(hEnv, "PATH"); 372 rc = RTPathTraverseList(pszPath, ':', rtPathFindExec, (void *)pszExec, &szRealExec[0]); 373 RTStrFree(pszPath); 374 if (RT_FAILURE(rc)) 375 return rc == VERR_END_OF_STRING ? VERR_FILE_NOT_FOUND : rc; 376 pszExec = szRealExec; 377 } 344 378 345 379 pid_t pid = -1;
Note:
See TracChangeset
for help on using the changeset viewer.