Changeset 3162 in kBuild
- Timestamp:
- Mar 20, 2018 3:13:12 AM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/redirect.c
r3161 r3162 979 979 StartupInfo.cb = sizeof(StartupInfo); 980 980 GetStartupInfoA(&StartupInfo); 981 StartupInfo.lpReserved2 = 0; /* No CRT file handle + descriptor info possible, sorry. */ 982 StartupInfo.cbReserved2 = 0; 981 983 StartupInfo.dwFlags &= ~STARTF_USESTDHANDLES; 982 984 … … 1034 1036 /* 1035 1037 * Start the process in suspended animation so we can inject handles. 1036 *1037 * We clear the reserved 2 pointer + size to avoid passing the wrong1038 * filehandle info to the child. We may later want to generate this.1039 1038 */ 1040 StartupInfo.cbReserved2 = 0;1041 StartupInfo.lpReserved2 = 0;1042 1043 1039 if (CreateProcessA(pszExecutable, pszCmdLine, NULL /*pProcAttrs*/, NULL /*pThreadAttrs*/, 1044 1040 FALSE /*fInheritHandles*/, CREATE_SUSPENDED, pszzEnv, pszCwd, &StartupInfo, &ProcInfo)) -
trunk/src/kmk/makeint.h
r3156 r3162 653 653 #define OSSNS(_t,_a,_f,_s1,_s2,_n,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3) + INTSTR_LENGTH, \ 654 654 (_f), (_s1), (_s2), (_n), (_s3)) /* bird */ 655 #define ONNS(_t,_a,_f,_n1,_n2,_s1) _t((_a), INTSTR_LENGTH * 2 + strlen (_s1), \ 656 (_f), (_n1), (_n2), (_s1)) /* bird */ 657 #define ONNNS(_t,_a,_f,_n1,_n2,_n3,_s1) _t((_a), INTSTR_LENGTH * 3 + strlen (_s1), \ 658 (_f), (_n1), (_n2), (_n3), (_s1)) /* bird */ 655 659 656 660 #define OUT_OF_MEM() O (fatal, NILF, _("virtual memory exhausted")) -
trunk/src/kmk/w32/winchildren.c
r3161 r3162 396 396 */ 397 397 InitializeSRWLock(&g_RWLock); 398 399 /* 400 * This is dead code that was thought to fix a problem observed doing 401 * `tcc.exe /c "kmk |& tee bld.log"` and leading to a crash in cl.exe 402 * when spawned with fInheritHandles = FALSE, see hStdErr=NULL in the 403 * child. However, it turns out this was probably caused by not clearing 404 * the CRT file descriptor and handle table in the startup info. 405 * Leaving the code here in case it comes in handy after all. 406 */ 407 #if 0 408 { 409 struct 410 { 411 DWORD uStdHandle; 412 HANDLE hHandle; 413 } aHandles[3] = { { STD_INPUT_HANDLE, NULL }, { STD_OUTPUT_HANDLE, NULL }, { STD_ERROR_HANDLE, NULL } }; 414 int i; 415 416 for (i = 0; i < 3; i++) 417 aHandles[i].hHandle = GetStdHandle(aHandles[i].uStdHandle); 418 419 for (i = 0; i < 3; i++) 420 if ( aHandles[i].hHandle == NULL 421 || aHandles[i].hHandle == INVALID_HANDLE_VALUE) 422 { 423 int fd = open("nul", _O_RDWR); 424 if (fd >= 0) 425 { 426 if (_dup2(fd, i) >= 0) 427 { 428 assert((HANDLE)_get_osfhandle(i) != aHandles[i].hHandle); 429 assert((HANDLE)_get_osfhandle(i) == GetStdHandle(aHandles[i].uStdHandle)); 430 } 431 else 432 ONNNS(fatal, NILF, "_dup2(%d('nul'), %d) failed: %u (%s)", fd, i, errno, strerror(errno)); 433 if (fd != i) 434 close(fd); 435 } 436 else 437 ONNS(fatal, NILF, "open(nul,RW) failed: %u (%s)", i, errno, strerror(errno)); 438 } 439 else 440 { 441 int j; 442 for (j = i + 1; j < 3; j++) 443 if (aHandles[j].hHandle == aHandles[i].hHandle) 444 { 445 int fd = _dup(j); 446 if (fd >= 0) 447 { 448 if (_dup2(fd, j) >= 0) 449 { 450 aHandles[j].hHandle = (HANDLE)_get_osfhandle(j); 451 assert(aHandles[j].hHandle != aHandles[i].hHandle); 452 assert(aHandles[j].hHandle == GetStdHandle(aHandles[j].uStdHandle)); 453 } 454 else 455 ONNNS(fatal, NILF, "_dup2(%d, %d) failed: %u (%s)", fd, j, errno, strerror(errno)); 456 if (fd != j) 457 close(fd); 458 } 459 else 460 ONNS(fatal, NILF, "_dup(%d) failed: %u (%s)", j, errno, strerror(errno)); 461 } 462 } 463 } 464 #endif 398 465 } 399 466 … … 538 605 StartupInfo.cb = sizeof(StartupInfo); 539 606 GetStartupInfoW(&StartupInfo); 607 StartupInfo.lpReserved2 = 0; /* No CRT file handle + descriptor info possible, sorry. */ 608 StartupInfo.cbReserved2 = 0; 540 609 if (!fHaveHandles) 541 610 StartupInfo.dwFlags &= ~STARTF_USESTDHANDLES; … … 544 613 fFlags |= CREATE_SUSPENDED; 545 614 StartupInfo.dwFlags &= ~STARTF_USESTDHANDLES; 546 547 /* Don't pass CRT inheritance info to the child (from our parent actually). */548 StartupInfo.cbReserved2 = 0;549 StartupInfo.lpReserved2 = 0;550 615 } 551 616 … … 2404 2469 } 2405 2470 2471 #if 0 /* no longer needed */ 2406 2472 /** Serialization with kmkbuiltin_redirect. */ 2407 2473 void MkWinChildExclusiveAcquire(void) … … 2415 2481 ReleaseSRWLockExclusive(&g_RWLock); 2416 2482 } 2483 #endif 2417 2484 2418 2485 /**
Note:
See TracChangeset
for help on using the changeset viewer.