Changeset 86412 in vbox for trunk/src/VBox/Runtime/r3/posix
- Timestamp:
- Oct 2, 2020 11:39:26 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 140713
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 /*
Note:
See TracChangeset
for help on using the changeset viewer.