Changeset 3666 for trunk/src/kmk/output.c
- Timestamp:
- Feb 21, 2025, 3:31:23 PM (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.