VirtualBox

Changeset 37356 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 7, 2011 5:04:39 PM (14 years ago)
Author:
vboxsync
Message:

Main/src-server/xpcom/server.cpp: fix handling of parameter passing when daemonizing VBoxSVC, only relevant when starting VBoxSVC explicitly and relying on PID files etc etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/xpcom/server.cpp

    r37179 r37356  
    713713}
    714714
    715 static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath)
     715static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath, bool fAutoShutdown, const char *pszPidFile)
    716716{
    717717    PRFileDesc *readable = nsnull, *writable = nsnull;
     
    719719    nsresult rv = NS_ERROR_FAILURE;
    720720    PRFileDesc *devNull;
     721    unsigned args_index = 0;
    721722    // The ugly casts are necessary because the PR_CreateProcessDetached has
    722723    // a const array of writable strings as a parameter. It won't write. */
    723     char * const args[] = { (char *)pszPath, (char *)"--auto-shutdown", 0 };
     724    char * args[1 + 1 + 2 + 1];
     725    args[args_index++] = (char *)pszPath;
     726    if (fAutoShutdown)
     727        args[args_index++] = (char *)"--auto-shutdown";
     728    if (pszPidFile)
     729    {
     730        args[args_index++] = (char *)"--pidfile";
     731        args[args_index++] = (char *)pszPidFile;
     732    }
     733    args[args_index++] = 0;
    724734
    725735    // Use a pipe to determine when the daemon process is in the position
     
    744754    PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, devNull);
    745755
    746     if (PR_CreateProcessDetached(pszPath, args, nsnull, attr) != PR_SUCCESS)
     756    if (PR_CreateProcessDetached(pszPath, (char * const *)args, nsnull, attr) != PR_SUCCESS)
    747757        goto end;
    748758
     
    848858    if (fDaemonize)
    849859    {
    850         vboxsvcSpawnDaemonByReExec(argv[0]);
     860        vboxsvcSpawnDaemonByReExec(argv[0], gAutoShutdown, g_pszPidFile);
    851861        exit(126);
    852862    }
Note: See TracChangeset for help on using the changeset viewer.

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