Changeset 14999 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Dec 4, 2008 5:12:09 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
r13837 r14999 64 64 RTR3DECL(int) RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess) 65 65 { 66 int rc; 67 66 68 /* 67 69 * Validate input. … … 69 71 AssertPtrReturn(pszExec, VERR_INVALID_POINTER); 70 72 AssertReturn(*pszExec, VERR_INVALID_PARAMETER); 71 AssertReturn( !fFlags, VERR_INVALID_PARAMETER);73 AssertReturn(fFlags & ~RTPROC_FLAGS_DAEMONIZE, VERR_INVALID_PARAMETER); 72 74 AssertReturn(Env != NIL_RTENV, VERR_INVALID_PARAMETER); 73 75 const char * const *papszEnv = RTEnvGetExecEnvP(Env); … … 110 112 pid_t pid; 111 113 #ifdef HAVE_POSIX_SPAWN 112 /** @todo check if it requires any of those two attributes, don't remember atm. */ 113 int rc = posix_spawn(&pid, pszExec, NULL, NULL, (char * const *)papszArgs, 114 if (!(fFlags & RTPROC_FLAGS_DAEMONIZE)) 115 { 116 /** @todo check if it requires any of those two attributes, don't remember atm. */ 117 rc = posix_spawn(&pid, pszExec, NULL, NULL, (char * const *)papszArgs, 114 118 (char * const *)papszEnv); 115 if (!rc) 116 { 117 if (pProcess) 118 *pProcess = pid; 119 return VINF_SUCCESS; 120 } 121 122 #else 123 124 pid = fork(); 125 if (!pid) 126 { 127 int rc; 128 rc = execve(pszExec, (char * const *)papszArgs, (char * const *)papszEnv); 129 AssertReleaseMsgFailed(("execve returns %d errno=%d\n", rc, errno)); 130 exit(127); 131 } 132 if (pid > 0) 133 { 134 if (pProcess) 135 *pProcess = pid; 136 return VINF_SUCCESS; 137 } 138 int rc = errno; 139 #endif 119 if (!rc) 120 { 121 if (pProcess) 122 *pProcess = pid; 123 return VINF_SUCCESS; 124 } 125 } 126 else 127 #endif 128 { 129 pid = fork(); 130 if (!pid) 131 { 132 if (fFlags & RTPROC_FLAGS_DAEMONIZE) 133 { 134 rc = RTProcDaemonize(true /* fNoChDir */, false /* fNoClose */, NULL /* pszPidFile */); 135 AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno)); 136 exit(127); 137 } 138 rc = execve(pszExec, (char * const *)papszArgs, (char * const *)papszEnv); 139 AssertReleaseMsgFailed(("execve returns %d errno=%d\n", rc, errno)); 140 exit(127); 141 } 142 if (pid > 0) 143 { 144 if (pProcess) 145 *pProcess = pid; 146 return VINF_SUCCESS; 147 } 148 int rc = errno; 149 } 140 150 141 151 /* failure, errno value in rc. */
Note:
See TracChangeset
for help on using the changeset viewer.