VirtualBox

Ignore:
Timestamp:
Jul 30, 2013 2:18:02 PM (11 years ago)
Author:
vboxsync
Message:

VBoxService/GuestCtrl: Forward ported r87539 + r87613 (4.2: VBoxService/VBoxServiceControlThread: (Another) fix for guest process timeout / pipe handling.).

File:
1 edited

Legend:

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

    r46513 r47475  
    718718            {
    719719                fProcessAlive = false;
    720                 continue;
    721             }
    722             if (RT_UNLIKELY(rc2 == VERR_INTERRUPTED))
    723                 continue;
    724             if (RT_UNLIKELY(rc2 == VERR_PROCESS_NOT_FOUND))
    725             {
    726                 fProcessAlive = false;
    727                 ProcessStatus.enmReason = RTPROCEXITREASON_ABEND;
    728                 ProcessStatus.iStatus   = 255;
    729                 AssertFailed();
     720                /* Note: Don't bail out here yet. First check in the next block below
     721                 *       if all needed pipe outputs have been consumed. */
    730722            }
    731723            else
    732                 AssertMsg(rc2 == VERR_PROCESS_RUNNING, ("%Rrc\n", rc2));
     724            {
     725                if (RT_UNLIKELY(rc2 == VERR_INTERRUPTED))
     726                    continue;
     727                if (RT_UNLIKELY(rc2 == VERR_PROCESS_NOT_FOUND))
     728                {
     729                    fProcessAlive = false;
     730                    ProcessStatus.enmReason = RTPROCEXITREASON_ABEND;
     731                    ProcessStatus.iStatus   = 255;
     732                    AssertFailed();
     733                }
     734                else
     735                    AssertMsg(rc2 == VERR_PROCESS_RUNNING, ("%Rrc\n", rc2));
     736            }
    733737        }
    734738
     
    737741         * we should be heading out.
    738742         */
    739         if (   !fProcessAlive
    740             && *phStdOutR == NIL_RTPIPE
    741             && *phStdErrR == NIL_RTPIPE)
    742         {
    743             VBoxServiceVerbose(3, "[PID %RU32]: All pipes closed, process not alive anymore, bailing out ...\n",
    744                                    pProcess->uPID);
    745             break;
     743        if (!fProcessAlive)
     744        {
     745            if (   fProcessTimedOut
     746                || (   *phStdOutR == NIL_RTPIPE
     747                    && *phStdErrR == NIL_RTPIPE)
     748               )
     749            {
     750                break;
     751            }
    746752        }
    747753
     
    757763            if (cMsElapsed >= pProcess->StartupInfo.uTimeLimitMS)
    758764            {
    759                 VBoxServiceVerbose(3, "[PID %RU32]: Timed out (%RU32ms elapsed > %RU32ms timeout), killing ...\n",
     765                VBoxServiceVerbose(3, "[PID %RU32]: Timed out (%RU64ms elapsed > %RU64ms timeout), killing ...\n",
    760766                                   pProcess->uPID, cMsElapsed, pProcess->StartupInfo.uTimeLimitMS);
    761767
     
    766772                    if (u64Now - MsProcessKilled > 20*60*1000)
    767773                        break; /* Give up after 20 mins. */
    768                     RTProcTerminate(hProcess);
     774                    rc2 = RTProcTerminate(hProcess);
     775                    VBoxServiceVerbose(3, "[PID %RU32]: Killing process resulted in rc=%Rrc\n",
     776                                       pProcess->uPID, rc2);
    769777                    MsProcessKilled = u64Now;
    770778                    continue;
     
    784792    }
    785793
    786     VBoxServiceVerbose(2, "[PID %RU32]: Process loop ended with rc=%Rrc\n",
    787                        pProcess->uPID, rc);
     794    VBoxServiceVerbose(3, "[PID %RU32]: Loop ended: fShutdown=%RTbool, fProcessAlive=%RTbool, fProcessTimedOut=%RTbool, MsProcessKilled=%RU32\n",
     795                       pProcess->uPID, pProcess->fShutdown, fProcessAlive, fProcessTimedOut, MsProcessKilled, MsProcessKilled);
     796    VBoxServiceVerbose(3, "[PID %RU32]: *phStdOutR=%s, *phStdErrR=%s\n",
     797                       pProcess->uPID, *phStdOutR == NIL_RTPIPE ? "closed" : "open", *phStdErrR == NIL_RTPIPE ? "closed" : "open");
    788798
    789799    /* Signal that this thread is in progress of shutting down. */
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