Changeset 2294 in kBuild for trunk/src/kash/shfile.c
- Timestamp:
- Feb 28, 2009 8:33:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shfile.c
r2293 r2294 381 381 if (getcwd(buf, sizeof(buf))) 382 382 { 383 pfdtab->cwd = s trdup(buf);383 pfdtab->cwd = sh_strdup(NULL, buf); 384 384 if (!inherit) 385 385 { … … 466 466 467 467 shmtx_enter(&pfdtab->mtx, &tmp); 468 TRACE2((NULL, "shfile_fork_win:\n")); 468 469 469 470 i = pfdtab->size; … … 473 474 { 474 475 HANDLE hFile = (HANDLE)pfdtab->tab[i].native; 475 DWORD fFlag = set || !pfdtab->tab[i].cloexec ? HANDLE_FLAG_INHERIT : 0; 476 DWORD fFlag = (set || !pfdtab->tab[i].cloexec) 477 ? HANDLE_FLAG_INHERIT : 0; 478 if (set) 479 TRACE2((NULL, " #%d: native=%#x flags=%#x cloexec=%d fFlag=%#x\n", 480 i, pfdtab->tab[i].flags, hFile, pfdtab->tab[i].cloexec, fFlag)); 481 476 482 if (!SetHandleInformation(hFile, HANDLE_FLAG_INHERIT, fFlag)) 477 483 { … … 613 619 int shfile_pipe(shfdtab *pfdtab, int fds[2]) 614 620 { 615 #ifdef SH_PURE_STUB_MODE 616 return -1; 621 int rc; 622 int s; 623 #ifdef SHFILE_IN_USE 624 # if K_OS == K_OS_WINDOWS 625 HANDLE hRead = INVALID_HANDLE_VALUE; 626 HANDLE hWrite = INVALID_HANDLE_VALUE; 627 SECURITY_ATTRIBUTES SecurityAttributes; 628 629 SecurityAttributes.nLength = sizeof(SecurityAttributes); 630 SecurityAttributes.lpSecurityDescriptor = NULL; 631 SecurityAttributes.bInheritHandle = TRUE; 632 633 if (!CreatePipe(&hRead, &hWrite, &SecurityAttributes, 4096)) 634 { 635 fds[0] = shfile_insert(pfdtab, (intptr_t)hRead, O_RDONLY, -1, "shfile_pipe"); 636 if (fds[0] != -1) 637 { 638 fds[1] = shfile_insert(pfdtab, (intptr_t)hWrite, O_WRONLY, -1, "shfile_pipe"); 639 if (fds[1] != -1) 640 rc = 0; 641 } 642 643 # else 644 int native_fds[2]; 645 if (!pipe(native_fds)) 646 { 647 fds[1] = -1; 648 fds[0] = shfile_insert(pfdtab, native_fds[0], O_RDONLY, -1, "shfile_pipe"); 649 if (fds[0] != -1) 650 { 651 fds[1] = shfile_insert(pfdtab, native_fds[1], O_WRONLY, -1, "shfile_pipe"); 652 if (fds[1] != -1) 653 rc = 0; 654 } 655 # endif 656 s = errno; 657 if (fds[1] == -1) 658 { 659 if (fds[0] != -1) 660 { 661 shmtxtmp tmp; 662 shmtx_enter(&pfdtab->mtx, &tmp); 663 rc = fds[0]; 664 pfdtab->tab[rc].fd = -1; 665 pfdtab->tab[rc].flags = 0; 666 pfdtab->tab[rc].native = -1; 667 shmtx_leave(&pfdtab->mtx, &tmp); 668 } 669 670 # if K_OS == K_OS_WINDOWS 671 CloseHandle(hRead); 672 CloseHandle(hWrite); 673 # else 674 close(native_fds[0]); 675 close(native_fds[1]); 676 # endif 677 fds[0] = fds[1] = -1; 678 errno = s; 679 rc = -1; 680 } 681 } 682 683 #elif defined(SH_PURE_STUB_MODE) 684 rc = -1; 685 errno = ENOSYS; 617 686 618 687 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) 619 688 # ifdef _MSC_VER 620 return _pipe(fds, PIPE_BUF, O_BINARY); 621 # else 622 return pipe(fds); 623 # endif 624 625 #else 626 #endif 689 rc = _pipe(fds, PIPE_BUF, O_BINARY); 690 # else 691 rc = pipe(fds); 692 # endif 693 #endif 694 695 TRACE2((NULL, "shfile_pipe() -> %d{%d,%d} [%d]\n", rc, fds[0], fds[1], errno)); 696 return rc; 627 697 } 628 698
Note:
See TracChangeset
for help on using the changeset viewer.