VirtualBox

Changeset 3662 in kBuild


Ignore:
Timestamp:
Feb 20, 2025 4:30:45 PM (3 weeks ago)
Author:
bird
Message:

kmk/output.c: Debugging code for the mysterious 'kmk: write error: stdout' problem...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/output.c

    r3563 r3662  
    5858#else
    5959# define STREAM_OK(_s) 1
     60#endif
     61
     62#if defined(KMK) && defined(KBUILD_OS_WINDOWS) && 1
     63/* fflush wrapper w/ error checking + reporting for stdout.
     64   This is to debug the mysterious 'kmk: write error: stdout' errors. */
     65int g_fStdOutError = 0;
     66
     67static int my_fflush (FILE *pFile)
     68{
     69  if (pFile == stdout && !g_fStdOutError)
     70    {
     71      if (!ferror (pFile))
     72        {
     73          int rcRet = fflush (pFile);
     74          g_fStdOutError = ferror(g_fStdOutError);
     75          if (rcRet != EOF && !g_fStdOutError)
     76            { /* likely */ }
     77          else if (rcRet == EOF)
     78            fprintf (stderr, "kmk: fflush(stdout): flush failed! errno=%d\n", errno);
     79          else
     80            fprintf (stderr, "kmk: fflush(stdout): error pending after successful flush! errno=%d\n", errno);
     81
     82          return rcRet;
     83        }
     84      else
     85        {
     86          fprintf (stderr, "kmk: fflush(stdout): error pending on entry! errno=%d\n", errno);
     87          g_fStdOutError = 1;
     88        }
     89
     90    }
     91  return fflush (pFile);
     92}
     93
     94# undef  fflush
     95# undef  fflush(a_pFile) my_fflush(a_pFile)
     96
    6097#endif
    6198
     
    194231            }
    195232          if (dst != prevdst)
    196             fflush(prevdst);
     233            fflush (prevdst);
    197234          prevdst = dst;
    198235#ifdef KMK
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette