VirtualBox

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


Ignore:
Timestamp:
Mar 7, 2011 10:55:00 AM (14 years ago)
Author:
vboxsync
Message:

VBoxService: Fix for reporting pre-init/terminated status, added -V (--version) for version information reporting.

File:
1 edited

Legend:

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

    r36182 r36183  
    138138             "    -f | --foreground       Don't daemonize the program. For debugging.\n"
    139139             "    -v | --verbose          Increment the verbosity level. For debugging.\n"
     140             "    -V | --version          Show version information.\n"
    140141             "    -h | -? | --help        Show this message and exit with status 1.\n"
    141142             );
     
    577578#endif
    578579
    579     VBoxServiceReportStatus(VBoxGuestFacilityStatus_PreInit);
    580 
    581     /*
    582      * Do pre-init of services.
    583      */
    584     for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
    585     {
    586         rc = g_aServices[j].pDesc->pfnPreInit();
    587         if (RT_FAILURE(rc))
    588         {
    589             VBoxServiceReportStatus(VBoxGuestFacilityStatus_Failed);
    590             return VBoxServiceError("Service '%s' failed pre-init: %Rrc\n", g_aServices[j].pDesc->pszName, rc);
    591         }
    592     }
    593 
    594580    /*
    595581     * Parse the arguments.
     
    615601            else if (MATCHES("verbose"))
    616602                psz = "v";
     603            else if (MATCHES("version"))
     604                psz = "V";
    617605            else if (MATCHES("help"))
    618606                psz = "h";
     
    682670                    break;
    683671
     672                case 'V':
     673                    RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
     674                    return RTEXITCODE_SUCCESS;
     675
    684676                case 'h':
    685677                case '?':
     
    699691                    for (unsigned j = 0; j < RT_ELEMENTS(g_aServices); j++)
    700692                    {
    701                         rc = g_aServices[j].pDesc->pfnOption(&psz, argc, argv, &i);
    702                         fFound = rc == 0;
     693                        rc = g_aServices[j].pDesc->pfnPreInit();
     694                        if (RT_FAILURE(rc))
     695                            return VBoxServiceError("Service '%s' failed pre-init: %Rrc\n", g_aServices[j].pDesc->pszName, rc);
     696                        else
     697                            rc = g_aServices[j].pDesc->pfnOption(&psz, argc, argv, &i);
     698                        fFound = rc == VINF_SUCCESS;
    703699                        if (fFound)
    704700                            break;
     
    781777#endif
    782778    {
     779        VBoxServiceReportStatus(VBoxGuestFacilityStatus_PreInit);
     780
    783781        /*
    784782         * Windows: We're running the service as a console application now. Start the
     
    794792            VBoxServiceMainWait();
    795793        VBoxServiceStopServices();
     794
     795        /* Only report the "terminated" status when we really did run the internal services --
     796         * otherwise we also wrongly would report "terminated" when a user simply
     797         * wants to query the version or the command line help. */
     798        VBoxServiceReportStatus(VBoxGuestFacilityStatus_Terminated);
    796799    }
    797800
     
    808811
    809812    VBoxServiceVerbose(0, "Ended.\n");
    810     VBoxServiceReportStatus(VBoxGuestFacilityStatus_Terminated);
    811813    return rcExit;
    812814}
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