Changeset 3666
- Timestamp:
- Feb 21, 2025, 3:31:23 PM (5 weeks ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/kmk/Makefile.kmk ¶
r3641 r3666 243 243 kmk_DEFS.win := CONFIG_WITH_OUTPUT_IN_MEMORY 244 244 kmk_DEFS.win.x86 := CONFIG_NEW_WIN32_CTRL_EVENT 245 kmk_DEFS.win.amd64 := CONFIG_NEW_WIN32_CTRL_EVENT 245 kmk_DEFS.win.amd64 := CONFIG_NEW_WIN32_CTRL_EVENT DEBUG_STDOUT_CLOSE_ISSUE 246 246 kmk_DEFS.debug := CONFIG_WITH_MAKE_STATS 247 247 ifdef CONFIG_WITH_MAKE_STATS -
TabularUnified trunk/src/kmk/output.c ¶
r3664 r3666 60 60 #endif 61 61 62 #if defined(KMK) && defined(KBUILD_OS_WINDOWS) && 1 63 # define DEBUG_STDOUT_CLOSE_ISSUE 62 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 64 63 /* fflush wrapper w/ error checking + reporting for stdout. 65 64 This is to debug the mysterious 'kmk: write error: stdout' errors. */ … … 68 67 static void my_stdout_error (const char *pszOperation, const char *pszMessage) 69 68 { 69 # ifdef KBUILD_OS_WINDOWS 70 70 DWORD const dwErr = GetLastError (); 71 # endif 71 72 int const iErrNo = errno; 72 int const fdFile = fileno(stdout); 73 int const fdFile = fileno (stdout); 74 # ifdef KBUILD_OS_WINDOWS 73 75 HANDLE const hNative = (HANDLE)_get_osfhandle (_fileno (stdout)); 74 76 DWORD const dwType = GetFileType (hNative); 75 fprintf (stderr, "kmk: %s: %s! (lasterr=%u errno=%d fileno=%d native=%p type=%#x)\n", 76 pszOperation, pszMessage, dwErr, iErrNo, fdFile, hNative, dwType); 77 fprintf (stderr, "kmk[%u]: %s: %s! (lasterr=%u errno=%d fileno=%d native=%p type=%#x)\n", 78 makelevel, pszOperation, pszMessage, dwErr, iErrNo, fdFile, hNative, dwType); 79 # else 80 fprintf (stderr, "kmk[%u]: %s: %s! (lasterr=%u errno=%d fileno=%d)\n", 81 makelevel, pszOperation, pszMessage, dwErr, iErrNo, fdFile); 82 # endif 77 83 } 78 84 … … 107 113 # define fflush(a_pFile) my_fflush(a_pFile) 108 114 109 #endif 115 /* Preserves errno and win32 last error. */ 116 void my_check_stdout (const char *pszWhere) 117 { 118 if (!g_fStdOutError) 119 { 120 # ifdef KBUILD_OS_WINDOWS 121 DWORD const dwErrSaved = GetLastError(); 122 # endif 123 int const iErrNoSaved = errno; 124 125 if (ferror (stdout)) 126 { 127 my_stdout_error (pszWhere, "error pending!"); 128 g_fStdOutError = 1; 129 } 130 131 errno = iErrNoSaved; 132 # ifdef KBUILD_OS_WINDOWS 133 SetLastError(dwErrSaved); 134 # endif 135 } 136 } 137 138 #endif /* DEBUG_STDOUT_CLOSE_ISSUE */ 110 139 111 140 -
TabularUnified trunk/src/kmk/output.h ¶
r3479 r3666 104 104 #endif 105 105 106 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 107 void my_check_stdout (const char *pszWhere); 108 #endif 109 106 110 #endif /* INLCUDED_MAKE_OUTPUT_H */ 107 111 -
TabularUnified trunk/src/kmk/w32/winchildren.c ¶
r3627 r3666 1287 1287 extern int process_priority; 1288 1288 #endif 1289 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 1290 my_check_stdout("mkWinChildcareWorkerCreateProcess/entry"); 1291 #endif 1289 1292 1290 1293 /* … … 1450 1453 CloseHandle(ProcInfo.hThread); 1451 1454 kmk_cache_exec_image_w(pwszImageName); 1455 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 1456 my_check_stdout("mkWinChildcareWorkerCreateProcess/tail"); 1457 #endif 1452 1458 return 0; 1453 1459 } … … 3589 3595 { 3590 3596 PWINCHILD pChild; 3597 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 3598 my_check_stdout ("MkWinChildWait/entry"); 3599 #endif 3591 3600 3592 3601 *pPid = 0; … … 3601 3610 { 3602 3611 DWORD dwStatus = WaitForSingleObject(g_hEvtWaitChildren, INFINITE); 3612 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 3613 my_check_stdout ("MkWinChildWait/wakeup"); 3614 #endif 3603 3615 if (dwStatus == WAIT_FAILED) 3604 3616 return (int)GetLastError(); … … 3641 3653 dir_cache_invalid_after_job(); 3642 3654 #endif 3655 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 3656 my_check_stdout ("MkWinChildWait/tail"); 3657 #endif 3643 3658 return 0; 3644 3659 } … … 3678 3693 WCHAR *pwszPathIgnored; 3679 3694 int rc; 3695 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 3696 my_check_stdout("MkWinChildReExecMake/entry"); 3697 #endif 3680 3698 3681 3699 /* … … 3744 3762 3745 3763 CloseHandle(ProcInfo.hProcess); 3764 #ifdef DEBUG_STDOUT_CLOSE_ISSUE 3765 my_check_stdout("MkWinChildReExecMake/exit"); 3766 #endif 3746 3767 for (;;) 3747 3768 exit(dwExitCode);
Note:
See TracChangeset
for help on using the changeset viewer.