Changeset 2733 in kBuild
- Timestamp:
- Oct 16, 2014 6:29:41 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/mscfakes.c
r2702 r2733 110 110 111 111 int 112 birdSetErrno( DWORDdwErr)112 birdSetErrno(unsigned dwErr) 113 113 { 114 114 switch (dwErr) … … 535 535 536 536 537 /** 538 * This is a kludge to make pipe handles blocking. 539 * 540 * @returns TRUE if it's now blocking, FALSE if not a pipe or we failed to fix 541 * the blocking mode. 542 * @param fd The libc file descriptor number. 543 */ 544 static BOOL makePipeBlocking(int fd) 545 { 546 /* Is pipe? */ 547 HANDLE hFile = (HANDLE)_get_osfhandle(fd); 548 if (hFile != INVALID_HANDLE_VALUE) 549 { 550 DWORD fType = GetFileType(hFile); 551 fType &= ~FILE_TYPE_REMOTE; 552 if (fType == FILE_TYPE_PIPE) 553 { 554 /* Try fix it. */ 555 DWORD fState = 0; 556 if (GetNamedPipeHandleState(hFile, &fState, NULL, NULL, NULL, NULL, 0)) 557 { 558 fState &= ~PIPE_NOWAIT; 559 fState |= PIPE_WAIT; 560 if (SetNamedPipeHandleState(hFile, &fState, NULL, NULL)) 561 return TRUE; 562 } 563 } 564 } 565 return FALSE; 566 } 567 568 569 /** 570 * Initializes the msc fake stuff. 571 * @returns 0 on success (non-zero would indicate failure, see rterr.h). 572 */ 573 int mscfake_init(void) 574 { 575 /* 576 * Kludge against _write returning ENOSPC on non-blocking pipes. 577 */ 578 makePipeBlocking(STDOUT_FILENO); 579 makePipeBlocking(STDERR_FILENO); 580 581 return 0; 582 } 583 584 /* 585 * Do this before main is called. 586 */ 587 #pragma section(".CRT$XIA", read) 588 #pragma section(".CRT$XIU", read) 589 #pragma section(".CRT$XIZ", read) 590 typedef int (__cdecl *PFNCRTINIT)(void); 591 static __declspec(allocate(".CRT$XIU")) PFNCRTINIT g_MscFakeInitVectorEntry = mscfake_init; 592
Note:
See TracChangeset
for help on using the changeset viewer.