- Timestamp:
- Jan 13, 2010, 2:45:49 AM (16 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/Makefile.kmk
r2315 r2376 191 191 endif 192 192 193 # 194 # For debugging file handle inheritance on Windows. 195 # 196 if "$(KBUILD_TARGET)" == win && 0 197 PROGRAMS += tstDump 198 tstDump_TEMPLATE = BIN 199 tstDump_SOURCES = tstDump.c 200 endif 201 193 202 # Include the sub-makefile. 194 203 include $(PATH_SUB_CURRENT)/tests/Makefile.kmk -
trunk/src/kash/shfile.c
r2312 r2376 548 548 if (hFile != INVALID_HANDLE_VALUE) 549 549 { 550 int fd2 = shfile_insert(pfdtab, (intptr_t)hFile, aStdHandles[i].fFlags, 0, i, "shtab_init"); 550 DWORD dwType = GetFileType(hFile); 551 unsigned fFlags = aStdHandles[i].fFlags; 552 unsigned fFlags2; 553 int fd2; 554 if (dwType == FILE_TYPE_CHAR) 555 fFlags2 = SHFILE_FLAGS_TTY; 556 else if (dwType == FILE_TYPE_PIPE) 557 fFlags2 = SHFILE_FLAGS_PIPE; 558 else 559 fFlags2 = SHFILE_FLAGS_FILE; 560 fd2 = shfile_insert(pfdtab, (intptr_t)hFile, fFlags, fFlags2, i, "shtab_init"); 551 561 assert(fd2 == i); (void)fd2; 552 562 if (fd2 != i) … … 588 598 589 599 shmtx_enter(&pfdtab->mtx, &tmp); 590 TRACE2((NULL, "shfile_fork_win: \n"));600 TRACE2((NULL, "shfile_fork_win: set=%d\n", set)); 591 601 592 602 i = pfdtab->size; … … 598 608 if (set) 599 609 TRACE2((NULL, " #%d: native=%#x oflags=%#x shflags=%#x\n", 600 i, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags, hFile));610 i, hFile, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags)); 601 611 if (!SetHandleInformation(hFile, HANDLE_FLAG_INHERIT, fFlag)) 602 612 { … … 612 622 { 613 623 if ( pfdtab->size > i 614 && pfdtab->tab[i].fd == 0)624 && pfdtab->tab[i].fd == i) 615 625 hndls[i] = pfdtab->tab[i].native; 616 626 else 617 627 hndls[i] = (intptr_t)INVALID_HANDLE_VALUE; 628 TRACE2((NULL, "shfile_fork_win: i=%d size=%d fd=%d native=%d hndls[%d]=%p\n", 629 i, pfdtab->size, pfdtab->tab[i].fd, pfdtab->tab[i].native, i, hndls[i])); 618 630 } 619 631 } … … 644 656 645 657 shmtx_enter(&pfdtab->mtx, &tmp); 646 TRACE2((NULL, "shfile_ fork_win:\n"));658 TRACE2((NULL, "shfile_exec_win: prepare=%p\n", prepare)); 647 659 648 660 count = pfdtab->size < (0x10000-4) / (1 + sizeof(HANDLE)) 649 661 ? pfdtab->size 650 662 : (0x10000-4) / (1 + sizeof(HANDLE)); 651 while (count > 3 && pfdtab->tab[count ].fd == -1)663 while (count > 3 && pfdtab->tab[count - 1].fd == -1) 652 664 count--; 653 665 … … 669 681 HANDLE hFile = (HANDLE)pfdtab->tab[i].native; 670 682 TRACE2((NULL, " #%d: native=%#x oflags=%#x shflags=%#x\n", 671 i, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags, hFile));683 i, hFile, pfdtab->tab[i].oflags, pfdtab->tab[i].shflags)); 672 684 673 685 if (!SetHandleInformation(hFile, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) … … 697 709 for (i = 0; i < 3; i++) 698 710 { 699 if ( count > i700 && pfdtab->tab[i].fd == 0)711 if ( i < count 712 && pfdtab->tab[i].fd == i) 701 713 hndls[i] = pfdtab->tab[i].native; 702 714 else 703 715 hndls[i] = (intptr_t)INVALID_HANDLE_VALUE; 716 TRACE2((NULL, "shfile_exec_win: i=%d count=%d fd=%d native=%d hndls[%d]=\n", 717 i, count, pfdtab->tab[i].fd, pfdtab->tab[i].native, i, hndls[i])); 704 718 } 705 719 -
trunk/src/kash/shinstance.c
r2362 r2376 899 899 #if K_OS == K_OS_WINDOWS //&& defined(SH_FORKED_MODE) 900 900 pid = shfork_do_it(psh); 901 if (pid == 0) 902 shthread_set_shell(psh); 901 903 902 904 #elif defined(SH_FORKED_MODE) … … 1141 1143 1142 1144 /* File handles. */ 1145 StrtInfo.dwFlags |= STARTF_USESTDHANDLES; 1143 1146 StrtInfo.lpReserved2 = shfile_exec_win(&psh->fdtab, 1 /* prepare */, &StrtInfo.cbReserved2, hndls); 1144 1147 StrtInfo.hStdInput = (HANDLE)hndls[0]; -
trunk/src/kash/show.c
r2297 r2376 273 273 # define TRY_GET_PSH_OR_RETURN(psh) \ 274 274 if (!(psh)) { \ 275 psh= shthread_get_shell(); \276 if (! psh) \275 (psh) = shthread_get_shell(); \ 276 if (!(psh)) \ 277 277 return; \ 278 278 } else do { } while (0)
Note:
See TracChangeset
for help on using the changeset viewer.