Changeset 86412 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Oct 2, 2020 11:39:26 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 140713
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/os2/pipe-os2.cpp
r82968 r86412 68 68 /** Set if this is the read end, clear if it's the write end. */ 69 69 bool fRead; 70 /** RTPipeFromNative: Leave open. */ 71 bool fLeaveOpen; 70 72 /** Whether the pipe is in blocking or non-blocking mode. */ 71 73 bool fBlocking; … … 195 197 pThisR->fRead = true; 196 198 pThisW->fRead = false; 199 pThisR->fLeaveOpen = false; 200 pThisW->fLeaveOpen = false; 197 201 pThisR->fBlocking = false; 198 202 pThisW->fBlocking = true; … … 227 231 228 232 229 RTDECL(int) RTPipeClose (RTPIPE hPipe)233 RTDECL(int) RTPipeCloseEx(RTPIPE hPipe, bool fLeaveOpen) 230 234 { 231 235 RTPIPEINTERNAL *pThis = hPipe; … … 243 247 244 248 /* Don't call DosDisConnectNPipe! */ 245 DosClose(pThis->hPipe); 249 if (!fLeaveOpen && !pThis->fLeaveOpen) 250 DosClose(pThis->hPipe); 246 251 pThis->hPipe = (HPIPE)-1; 247 252 … … 261 266 262 267 268 RTDECL(int) RTPipeClose(RTPIPE hPipe) 269 { 270 return RTPipeCloseEx(hPipe, false /*fLeaveOpen*/); 271 } 272 273 263 274 RTDECL(int) RTPipeFromNative(PRTPIPE phPipe, RTHCINTPTR hNativePipe, uint32_t fFlags) 264 275 { 265 276 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); 267 278 AssertReturn(!!(fFlags & RTPIPE_N_READ) != !!(fFlags & RTPIPE_N_WRITE), VERR_INVALID_PARAMETER); 268 279 … … 333 344 pThis->hPipe = hNative; 334 345 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); 336 348 pThis->fBlocking = !(fPipeState & NP_NOWAIT); 337 349 //pThis->fBrokenPipe = false; -
trunk/src/VBox/Runtime/r3/posix/pipe-posix.cpp
r82968 r86412 70 70 /** Set if this is the read end, clear if it's the write end. */ 71 71 bool fRead; 72 /** RTPipeFromNative: Leave it open on RTPipeClose. */ 73 bool fLeaveOpen; 72 74 /** Atomically operated state variable. 73 75 * … … 181 183 if (pThisW) 182 184 { 183 pThisR->u32Magic = RTPIPE_MAGIC; 184 pThisW->u32Magic = RTPIPE_MAGIC; 185 pThisR->fd = aFds[0]; 186 pThisW->fd = aFds[1]; 187 pThisR->fRead = true; 188 pThisW->fRead = false; 189 pThisR->u32State = RTPIPE_POSIX_BLOCKING; 190 pThisW->u32State = RTPIPE_POSIX_BLOCKING; 185 pThisR->u32Magic = RTPIPE_MAGIC; 186 pThisW->u32Magic = RTPIPE_MAGIC; 187 pThisR->fd = aFds[0]; 188 pThisW->fd = aFds[1]; 189 pThisR->fRead = true; 190 pThisW->fRead = false; 191 pThisR->fLeaveOpen = false; 192 pThisW->fLeaveOpen = false; 193 pThisR->u32State = RTPIPE_POSIX_BLOCKING; 194 pThisW->u32State = RTPIPE_POSIX_BLOCKING; 191 195 192 196 *phPipeRead = pThisR; … … 213 217 214 218 215 RTDECL(int) RTPipeClose (RTPIPE hPipe)219 RTDECL(int) RTPipeCloseEx(RTPIPE hPipe, bool fLeaveOpen) 216 220 { 217 221 RTPIPEINTERNAL *pThis = hPipe; … … 228 232 int fd = pThis->fd; 229 233 pThis->fd = -1; 230 close(fd); 234 if (!fLeaveOpen && !pThis->fLeaveOpen) 235 close(fd); 231 236 232 237 if (ASMAtomicReadU32(&pThis->u32State) & RTPIPE_POSIX_USERS_MASK) … … 241 246 } 242 247 248 249 RTDECL(int) RTPipeClose(RTPIPE hPipe) 250 { 251 return RTPipeCloseEx(hPipe, false /*fLeaveOpen*/); 252 } 253 254 243 255 RTDECL(int) RTPipeFromNative(PRTPIPE phPipe, RTHCINTPTR hNativePipe, uint32_t fFlags) 244 256 { 245 257 AssertPtrReturn(phPipe, VERR_INVALID_POINTER); 246 AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK ), VERR_INVALID_PARAMETER);258 AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK_FN), VERR_INVALID_PARAMETER); 247 259 AssertReturn(!!(fFlags & RTPIPE_N_READ) != !!(fFlags & RTPIPE_N_WRITE), VERR_INVALID_PARAMETER); 248 260 … … 268 280 return VERR_NO_MEMORY; 269 281 270 pThis->u32Magic = RTPIPE_MAGIC; 271 pThis->fd = hNative; 272 pThis->fRead = !!(fFlags & RTPIPE_N_READ); 273 pThis->u32State = fFd & O_NONBLOCK ? 0 : RTPIPE_POSIX_BLOCKING; 282 pThis->u32Magic = RTPIPE_MAGIC; 283 pThis->fd = hNative; 284 pThis->fRead = RT_BOOL(fFlags & RTPIPE_N_READ); 285 pThis->fLeaveOpen = RT_BOOL(fFlags & RTPIPE_N_LEAVE_OPEN); 286 pThis->u32State = fFd & O_NONBLOCK ? 0 : RTPIPE_POSIX_BLOCKING; 274 287 275 288 /* -
trunk/src/VBox/Runtime/r3/win/pipe-win.cpp
r82968 r86412 67 67 /** Set if this is the read end, clear if it's the write end. */ 68 68 bool fRead; 69 /** RTPipeFromNative: Leave native handle open on RTPipeClose. */ 70 bool fLeaveOpen; 69 71 /** Set if there is already pending I/O. */ 70 72 bool fIOPending; … … 284 286 pThisR->fRead = true; 285 287 pThisW->fRead = false; 288 pThisR->fLeaveOpen = false; 289 pThisW->fLeaveOpen = false; 286 290 //pThisR->fIOPending = false; 287 291 //pThisW->fIOPending = false; … … 400 404 401 405 402 RTDECL(int) RTPipeClose (RTPIPE hPipe)406 RTDECL(int) RTPipeCloseEx(RTPIPE hPipe, bool fLeaveOpen) 403 407 { 404 408 RTPIPEINTERNAL *pThis = hPipe; … … 418 422 rtPipeWriteCheckCompletion(pThis); 419 423 420 CloseHandle(pThis->hPipe); 424 if (!fLeaveOpen && !pThis->fLeaveOpen) 425 CloseHandle(pThis->hPipe); 421 426 pThis->hPipe = INVALID_HANDLE_VALUE; 422 427 … … 436 441 437 442 443 RTDECL(int) RTPipeClose(RTPIPE hPipe) 444 { 445 return RTPipeCloseEx(hPipe, false /*fLeaveOpen*/); 446 } 447 448 438 449 RTDECL(int) RTPipeFromNative(PRTPIPE phPipe, RTHCINTPTR hNativePipe, uint32_t fFlags) 439 450 { 440 451 AssertPtrReturn(phPipe, VERR_INVALID_POINTER); 441 AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK ), VERR_INVALID_PARAMETER);452 AssertReturn(!(fFlags & ~RTPIPE_N_VALID_MASK_FN), VERR_INVALID_PARAMETER); 442 453 AssertReturn(!!(fFlags & RTPIPE_N_READ) != !!(fFlags & RTPIPE_N_WRITE), VERR_INVALID_PARAMETER); 443 454 … … 482 493 pThis->u32Magic = RTPIPE_MAGIC; 483 494 pThis->hPipe = hNative; 484 pThis->fRead = !!(fFlags & RTPIPE_N_READ); 495 pThis->fRead = RT_BOOL(fFlags & RTPIPE_N_READ); 496 pThis->fLeaveOpen = RT_BOOL(fFlags & RTPIPE_N_LEAVE_OPEN); 485 497 //pThis->fIOPending = false; 486 498 //pThis->fZeroByteRead = false; … … 510 522 pThis->hPipe = hNative2; 511 523 if (rtPipeQueryNtInfo(pThis, &Info)) 524 { 525 pThis->fLeaveOpen = false; 512 526 rc = VINF_SUCCESS; 527 } 513 528 else 514 529 { … … 552 567 if (hNative2 != INVALID_HANDLE_VALUE) 553 568 { 554 if ( hNative != GetStdHandle(STD_INPUT_HANDLE) 569 if ( !(fFlags & RTPIPE_N_LEAVE_OPEN) 570 && hNative != GetStdHandle(STD_INPUT_HANDLE) 555 571 && hNative != GetStdHandle(STD_OUTPUT_HANDLE) 556 && hNative != GetStdHandle(STD_ERROR_HANDLE) )572 && hNative != GetStdHandle(STD_ERROR_HANDLE) ) 557 573 CloseHandle(hNative); 558 574 }
Note:
See TracChangeset
for help on using the changeset viewer.