Ignore:
Timestamp:
Mar 28, 2018, 10:32:11 PM (7 years ago)
Author:
bird
Message:

kmk,kWorker: Some fixes wrt output capture and ctrl-c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kWorker/kWorker.c

    r3199 r3200  
    95349534KU32 const                  g_cSandboxGetProcReplacements = K_ELEMENTS(g_aSandboxGetProcReplacements);
    95359535
    9536 /**
    9537  * Thread that is spawned by the first terminal kwSandboxCtrlHandler invocation.
    9538  *
    9539  * This will wait 5 second in a hope that the main thread will shut down the
    9540  * process nicly, otherwise it will terminate it forcefully.
    9541  */
    9542 static DWORD WINAPI kwSandboxCtrlThreadProc(PVOID pvUser)
    9543 {
    9544     int i;
    9545     for (i = 0; i < 10; i++)
    9546     {
    9547         Sleep(500);
    9548         CancelIoEx(g_hPipe, NULL);
    9549     }
    9550     TerminateProcess(GetCurrentProcess(), (int)(intptr_t)pvUser);
    9551     return -1;
    9552 }
    9553 
    95549536
    95559537/**
     
    95999581    /*
    96009582     * Terminate the process after 5 seconds.
    9601      *
    9602      * We don't want to wait here as the console server will otherwise not
    9603      * signal the other processes in the console, which is bad for kmk as it
    9604      * will continue to forge ahead.  So, the first time we get here we start
    9605      * a thread for doing the delayed termination.
    9606      *
    96079583     * If we get here a second time we just terminate the process ourselves.
    96089584     *
     
    96139589    g_rcCtrlC = rc;
    96149590    WriteFile(GetStdHandle(STD_ERROR_HANDLE), pszMsg, (DWORD)strlen(pszMsg), &cbIgn, NULL);
    9615     CancelIoEx(g_hPipe, NULL); /* wake up idle main thread */
    96169591    if (rcPrev == 0)
    96179592    {
    9618         CreateThread(NULL, 0, kwSandboxCtrlThreadProc, (void*)(intptr_t)rc, 0 /*fFlags*/, NULL);
    9619         return TRUE;
     9593        int i;
     9594        for (i = 0; i < 10; i++)
     9595        {
     9596            CancelIoEx(g_hPipe, NULL); /* wake up idle main thread */
     9597            Sleep(500);
     9598        }
    96209599    }
    96219600    TerminateProcess(GetCurrentProcess(), rc);
Note: See TracChangeset for help on using the changeset viewer.