~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/Main/src-server/xpcom/server.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
712
712
    }
713
713
}
714
714
 
715
 
static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath)
 
715
static nsresult vboxsvcSpawnDaemonByReExec(const char *pszPath, bool fAutoShutdown, const char *pszPidFile)
716
716
{
717
717
    PRFileDesc *readable = nsnull, *writable = nsnull;
718
718
    PRProcessAttr *attr = nsnull;
719
719
    nsresult rv = NS_ERROR_FAILURE;
720
720
    PRFileDesc *devNull;
 
721
    unsigned args_index = 0;
721
722
    // The ugly casts are necessary because the PR_CreateProcessDetached has
722
723
    // 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;
724
734
 
725
735
    // Use a pipe to determine when the daemon process is in the position
726
736
    // to actually process requests. The daemon will write "READY" to the pipe.
743
753
    PR_ProcessAttrSetStdioRedirect(attr, PR_StandardOutput, devNull);
744
754
    PR_ProcessAttrSetStdioRedirect(attr, PR_StandardError, devNull);
745
755
 
746
 
    if (PR_CreateProcessDetached(pszPath, args, nsnull, attr) != PR_SUCCESS)
 
756
    if (PR_CreateProcessDetached(pszPath, (char * const *)args, nsnull, attr) != PR_SUCCESS)
747
757
        goto end;
748
758
 
749
759
    // Close /dev/null
847
857
 
848
858
    if (fDaemonize)
849
859
    {
850
 
        vboxsvcSpawnDaemonByReExec(argv[0]);
 
860
        vboxsvcSpawnDaemonByReExec(argv[0], gAutoShutdown, g_pszPidFile);
851
861
        exit(126);
852
862
    }
853
863