VirtualBox

Ignore:
Timestamp:
Mar 26, 2010 2:50:55 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59375
Message:

IPRT,*: Renamed RTProcDaemonize to RTProcDaemonizeUsingFork. Added a new RTPRocDaemonize that is portable. RTProcCreate* got a new flag RTPROC_FLAGS_DETACHED, while RTPROC_FLAGS_DAEMONIZE got renamed to RTPROC_FLAGS_DAEMONIZE_DEPRECATED.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/process-posix.cpp

    r27667 r27743  
    8787    AssertPtrReturn(pszExec, VERR_INVALID_POINTER);
    8888    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);
    9091    AssertReturn(hEnv != NIL_RTENV, VERR_INVALID_PARAMETER);
    9192    const char * const *papszEnv = RTEnvGetExecEnvP(hEnv);
     
    175176    pid_t pid = -1;
    176177#ifdef HAVE_POSIX_SPAWN
    177     if (   !(fFlags & RTPROC_FLAGS_DAEMONIZE)
     178    if (   !(fFlags & (RTPROC_FLAGS_DAEMONIZE_DEPRECATED | RTPROC_FLAGS_DETACHED))
    178179        && uid == ~(uid_t)0
    179180        && gid == ~(gid_t)0
     
    303304             * Daemonize the process if requested.
    304305             */
    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 */);
    308311                if (RT_FAILURE(rc))
    309312                {
     313                    /* parent */
    310314                    AssertReleaseMsgFailed(("RTProcDaemonize returns %Rrc errno=%d\n", rc, errno));
    311315                    exit(127);
    312316                }
     317                /* daemonized child */
    313318            }
    314319
     
    424429
    425430
    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)
     431RTR3DECL(int)   RTProcDaemonizeUsingFork(bool fNoChDir, bool fNoClose, const char *pszPidfile)
    438432{
    439433    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette