VirtualBox

Changeset 3200 in kBuild


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

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

Location:
trunk/src
Files:
5 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);
  • trunk/src/kmk/kmkbuiltin/kSubmit.c

    r3199 r3200  
    7171
    7272#define TUPLE(a_sz)     a_sz, sizeof(a_sz) - 1
     73
    7374
    7475/*********************************************************************************************************************************
     
    11511152# else
    11521153        if (MkWinChildCreateSubmit((intptr_t)pWorker->OverlappedRead.hEvent, pWorker,
    1153                                    pWorker->pStdOut, pWorker->pStdErr, pPidSpawned) == 0)
     1154                                   pWorker->pStdOut, pWorker->pStdErr, pChild, pPidSpawned) == 0)
    11541155        { /* likely */ }
    11551156        else
     
    16911692               the kWorker process currently does not coordinate its output with
    16921693               the output.c mechanics. */
     1694#ifdef CONFIG_NEW_WIN_CHILDREN
     1695            if (pCtx->pOut && !pWorker->pStdOut)
     1696#else
    16931697            if (pCtx->pOut)
     1698#endif
    16941699                output_dump(pCtx->pOut);
    1695 
    16961700            rcExit = kSubmitSendJobMessage(pCtx, pWorker, pvMsg, cbMsg, 0 /*fNoRespawning*/, cVerbosity);
    16971701            if (rcExit == 0)
  • trunk/src/kmk/output.c

    r3195 r3200  
    131131              const char *nl = (const char *)memchr (src, '\n', len);
    132132              size_t line_len = nl ? nl - (const char *)src + 1 : len;
    133               char *tmp = (char *)xmalloc (2 + line_len + 1);
    134               tmp[0] = '>';
    135               tmp[1] = ' ';
    136               memcpy (&tmp[2], src, line_len);
     133              char *tmp = (char *)xmalloc (1 + line_len + 1 + 1);
     134              tmp[0] = '{';
     135              memcpy (&tmp[1], src, line_len);
     136              tmp[1 + line_len] = '}';
    137137#  ifdef KBUILD_OS_WINDOWS
    138               maybe_con_fwrite (tmp, 2 + line_len, 1, dst);
     138              maybe_con_fwrite (tmp, 1 + line_len + 1, 1, dst);
    139139#  else
    140               fwrite (tmp, 2 + line_len, 1, dst);
     140              fwrite (tmp, 1 + line_len + 1, 1, dst);
    141141#  endif
    142142              free (tmp);
  • trunk/src/kmk/w32/winchildren.c

    r3199 r3200  
    31183118 * @param   hEvent          The event object handle to wait on.
    31193119 * @param   pvSubmitWorker  The argument to pass back to kSubmit to clean up.
    3120  * @param   pPid            Where to return the pid.
    31213120 * @param   pStdOut         Standard output pipe for the worker. Optional.
    31223121 * @param   pStdErr         Standard error pipe for the worker. Optional.
    3123  */
    3124 int MkWinChildCreateSubmit(intptr_t hEvent, void *pvSubmitWorker, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr, pid_t *pPid)
     3122 * @param   pMkChild        The make child structure.
     3123 * @param   pPid            Where to return the pid.
     3124 */
     3125int MkWinChildCreateSubmit(intptr_t hEvent, void *pvSubmitWorker, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr,
     3126                           struct child *pMkChild, pid_t *pPid)
    31253127{
    31263128    PWINCHILD pChild = mkWinChildNew(WINCHILDTYPE_SUBMIT);
     3129    pChild->pMkChild                = pMkChild;
    31273130    pChild->u.Submit.hEvent         = (HANDLE)hEvent;
    31283131    pChild->u.Submit.pvSubmitWorker = pvSubmitWorker;
  • trunk/src/kmk/w32/winchildren.h

    r3199 r3200  
    7575                               struct child *pMkChild, pid_t *pPid);
    7676
    77 int     MkWinChildCreateSubmit(intptr_t hEvent, void *pvSubmitWorker, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr, pid_t *pPid);
     77int     MkWinChildCreateSubmit(intptr_t hEvent, void *pvSubmitWorker, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr,
     78                               struct child *pMkChild, pid_t *pPid);
    7879PWINCCWPIPE MkWinChildcareCreateWorkerPipe(unsigned iWhich, unsigned int idxWorker);
    7980void    MkWinChildcareWorkerDrainPipes(struct WINCHILD *pChild, PWINCCWPIPE pStdOut, PWINCCWPIPE pStdErr);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette