Changeset 27743 in vbox for trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
- Timestamp:
- Mar 26, 2010 2:50:55 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59375
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
r27667 r27743 87 87 AssertPtrReturn(pszExec, VERR_INVALID_POINTER); 88 88 AssertReturn(*pszExec, VERR_INVALID_PARAMETER); 89 AssertReturn(!(fFlags & ~RTPROC_FLAGS_DAEMONIZE), VERR_INVALID_PARAMETER); 89 AssertReturn(!(fFlags & ~(RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED)), VERR_INVALID_PARAMETER); 90 AssertReturn(!(fFlags & RTPROC_FLAGS_DETACHED) || !phProcess, VERR_INVALID_PARAMETER); 90 91 AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER); 91 92 const char * const *papszEnv = RTEnvGetExecEnvP(hEnv); … … 175 176 pid_t pid = -1; 176 177 #ifdef HAVE_POSIX_SPAWN 177 if ( !(fFlags & RTPROC_FLAGS_DAEMONIZE)178 if ( !(fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED)) 178 179 && uid == ~(uid_t)0 179 180 && gid == ~(gid_t)0 … … 303 304 * Daemonize the process if requested. 304 305 */ 305 if (fFlags & RTPROC_FLAGS_DAEMONIZE) 306 { 307 rc = RTProcDaemonize(true /* fNoChDir */, false /* fNoClose */, NULL /* pszPidFile */); 306 if (fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED)) 307 { 308 rc = RTProcDaemonizeUsingFork(true /*fNoChDir*/, 309 !(fFlags & RTPROC_FLAGS_DAEMONIZE_DEPRECATED) /*fNoClose*/, 310 NULL /* pszPidFile */); 308 311 if (RT_FAILURE(rc)) 309 312 { 313 /* parent */ 310 314 AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno)); 311 315 exit(127); 312 316 } 317 /* daemonized child */ 313 318 } 314 319 … … 424 429 425 430 426 /** 427 * Daemonize the current process, making it a background process. The current 428 * process will exit if daemonizing is successful. 429 * 430 * @returns iprt status code. 431 * @param fNoChDir Pass false to change working directory to "/". 432 * @param fNoClose Pass false to redirect standard file streams to the null device. 433 * @param pszPidfile Path to a file to write the process id of the daemon 434 * process to. Daemonizing will fail if this file already 435 * exists or cannot be written. May be NULL. 436 */ 437 RTR3DECL(int) RTProcDaemonize(bool fNoChDir, bool fNoClose, const char *pszPidfile) 431 RTR3DECL(int) RTProcDaemonizeUsingFork(bool fNoChDir, bool fNoClose, const char *pszPidfile) 438 432 { 439 433 /*
Note:
See TracChangeset
for help on using the changeset viewer.