VirtualBox

Changeset 86412 in vbox for trunk/src/VBox/Runtime/r3/os2


Ignore:
Timestamp:
Oct 2, 2020 11:39:26 AM (4 years ago)
Author:
vboxsync
Message:

IPRT/pipe: Adding RTPipeCloseEx w/ a fLeaveOpen parameter so we can prevent leaks via RTHandleGetStandard. Adding RTPIPE_N_LEAVE_OPEN to RTPipeFromNative. bugref:9841

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/os2/pipe-os2.cpp

    r82968 r86412  
    6868    /** Set if this is the read end, clear if it's the write end. */
    6969    bool                fRead;
     70    /** RTPipeFromNative: Leave open. */
     71    bool                fLeaveOpen;
    7072    /** Whether the pipe is in blocking or non-blocking mode. */
    7173    bool                fBlocking;
     
    195197                    pThisR->fRead           = true;
    196198                    pThisW->fRead           = false;
     199                    pThisR->fLeaveOpen      = false;
     200                    pThisW->fLeaveOpen      = false;
    197201                    pThisR->fBlocking       = false;
    198202                    pThisW->fBlocking       = true;
     
    227231
    228232
    229 RTDECL(int)  RTPipeClose(RTPIPE hPipe)
     233RTDECL(int)  RTPipeCloseEx(RTPIPE hPipe, bool fLeaveOpen)
    230234{
    231235    RTPIPEINTERNAL *pThis = hPipe;
     
    243247
    244248    /* Don't call DosDisConnectNPipe! */
    245     DosClose(pThis->hPipe);
     249    if (!fLeaveOpen && !pThis->fLeaveOpen)
     250        DosClose(pThis->hPipe);
    246251    pThis->hPipe = (HPIPE)-1;
    247252
     
    261266
    262267
     268RTDECL(int)  RTPipeClose(RTPIPE hPipe)
     269{
     270    return RTPipeCloseEx(hPipe, false /*fLeaveOpen*/);
     271}
     272
     273
    263274RTDECL(int)  RTPipeFromNative(PRTPIPE phPipe, RTHCINTPTR hNativePipe, uint32_t fFlags)
    264275{
    265276    AssertPtrReturn(phPipe, VERR_INVALID_POINTER);
    266     AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK), VERR_INVALID_PARAMETER);
     277    AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK_FN), VERR_INVALID_PARAMETER);
    267278    AssertReturn(!!(fFlags & RTPIPE_N_READ) != !!(fFlags & RTPIPE_N_WRITE), VERR_INVALID_PARAMETER);
    268279
     
    333344        pThis->hPipe           = hNative;
    334345        pThis->hev             = NULLHANDLE;
    335         pThis->fRead           = !!(fFlags & RTPIPE_N_READ);
     346        pThis->fRead           = RT_BOOL(fFlags & RTPIPE_N_READ);
     347        pThis->fLeaveOpen      = RT_BOOL(fFlags & RTPIPE_N_LEAVE_OPEN);
    336348        pThis->fBlocking       = !(fPipeState & NP_NOWAIT);
    337349        //pThis->fBrokenPipe     = false;
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