VirtualBox

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


Ignore:
Timestamp:
Sep 14, 2015 8:12:50 AM (9 years ago)
Author:
vboxsync
Message:

VBoxService: s/vboxServiceCreatePidFile/VbglR3PidFile/

File:
1 edited

Legend:

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

    r57721 r57729  
    289289{
    290290    RTLogDestroy(RTLogRelSetDefaultInstance(NULL));
    291 }
    292 
    293 /*
    294  * Create the PID file.
    295  */
    296 int vboxServiceCreatePidFile(const char *pszPidFile)
    297 {
    298     RTFILE hFile;
    299     int rc = RTFileOpen(&hFile, pszPidFile, RTFILE_O_WRITE | RTFILE_O_TRUNCATE);
    300     if (RT_SUCCESS(rc))
    301     {
    302         char szPid[32];
    303         RTPROCESS Process = RTProcSelf();
    304         size_t cb = RTStrPrintf(szPid, sizeof(szPid), "%RU64\n", (uint64_t)Process);
    305         rc = RTFileWrite(hFile, szPid, cb, NULL);
    306         int rc2 = RTFileClose(hFile);
    307         if (RT_SUCCESS(rc))
    308             rc = rc2;
    309     }
    310     if (RT_FAILURE(rc))
    311         VBoxServiceError("Failed to create PID file: %Rrc\n", rc);
    312     return rc;
    313291}
    314292
     
    11611139#endif /* RT_OS_WINDOWS */
    11621140        rc = VBoxServiceStartServices();
     1141        RTFILE hPidFile = NIL_RTFILE;
    11631142        if (RT_SUCCESS(rc))
    1164         {
    1165             if (strlen(g_szPidFile))
    1166                 rc = vboxServiceCreatePidFile(g_szPidFile);
    1167         }
     1143            if (g_szPidFile[0])
     1144                rc = VbglR3PidFile(g_szPidFile, &hPidFile);
    11681145        rcExit = RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
    11691146        if (RT_SUCCESS(rc))
    11701147            VBoxServiceMainWait();
     1148        if (g_szPidFile[0] && hPidFile != NIL_RTFILE)
     1149            VbglR3ClosePidFile(g_szPidFile, hPidFile);
    11711150#ifdef RT_OS_WINDOWS
    11721151# ifndef RT_OS_NT4
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