VirtualBox

Changeset 54010 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jan 28, 2015 12:21:54 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97918
Message:

Additions/common/VBoxGuestLib: add respawn counter to Daemonize().

Location:
trunk/src/VBox/Additions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDaemonize.cpp

    r53421 r54010  
    6969 * @param   fRespawn    Restart the daemonised process after five seconds if it
    7070 *                      terminates abnormally.
     71 * @param   pcRespawn   Where to store a count of how often we have respawned,
     72 *                      intended for avoiding error spamming.  Optional.
    7173 *
    7274 * @todo    Use RTProcDaemonize instead of this.
     
    7577 *          actually needs that.
    7678 */
    77 VBGLR3DECL(int) VbglR3Daemonize(bool fNoChDir, bool fNoClose, bool fRespawn)
     79VBGLR3DECL(int) VbglR3Daemonize(bool fNoChDir, bool fNoClose, bool fRespawn, unsigned *pcRespawn)
    7880{
    7981#if defined(RT_OS_OS2)
     
    219221
    220222    if (fRespawn)
     223    {
    221224        /* We implement re-spawning as a third fork(), with the parent process
    222225         * monitoring the child and re-starting it after a delay if it exits
    223226         * abnormally. */
     227        unsigned cRespawn = 0;
    224228        for (;;)
    225229        {
    226230            int iStatus, rcWait;
    227231
     232            if (pcRespawn != NULL)
     233                *pcRespawn = cRespawn;
    228234            pid = fork();
    229235            if (pid == -1)
     
    239245                exit(0);
    240246            sleep(5);
     247            ++cRespawn;
    241248        }
     249    }
    242250    return VINF_SUCCESS;
    243251#endif
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r53764 r54010  
    10991099        VBoxServiceVerbose(1, "Daemonizing...\n");
    11001100        rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */,
    1101                              false /* fRespawn */);
     1101                             false /* fRespawn */, NULL /* pcRespawn */);
    11021102        if (RT_FAILURE(rc))
    11031103            return VBoxServiceError("Daemon failed: %Rrc\n", rc);
  • trunk/src/VBox/Additions/x11/VBoxClient/main.cpp

    r54008 r54010  
    371371        VBClFatalError(("Creating pid-file path: %Rrc\n", rc));
    372372    if (fDaemonise)
    373         rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */, fRespawn);
     373        rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */, fRespawn, NULL);
    374374    if (RT_FAILURE(rc))
    375375        VBClFatalError(("Daemonizing: %Rrc\n", rc));
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