diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 90441627b..f8217be34 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2005-12-20 Corinna Vinschen + + * winsup.h (flush_file_buffers): Declare new function. + (FLushFileBuffers): New define. + * miscfuncs.cc (flush_file_buffers): Define new function. + 2005-12-20 Christopher Faylor * fhandler.h (fhandler_termios::fixup_after_exec): Make non-inlined. diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 26686bd2b..474843a19 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -361,3 +361,14 @@ create_pipe (PHANDLE hr,PHANDLE hw, LPSECURITY_ATTRIBUTES sa, DWORD n) break; return false; } + +#undef FlushFileBuffers +bool +flush_file_buffers (HANDLE h) +{ + DWORD ftype = GetFileType (h); + /* Per MSDN, FlushFileBuffers on named pipes might block. This is the last + we want it to do, especially when printing debug output as when calling + system_printf. */ + return (ftype != FILE_TYPE_PIPE) ? FlushFileBuffers (h) : true; +} diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 72d5aab22..080bb03c9 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -309,6 +309,8 @@ DWORD nice_to_winprio (int &) __attribute__ ((regparm (1))); bool __stdcall create_pipe (PHANDLE hr, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD) __attribute__ ((regparm (3))); #define CreatePipe create_pipe +bool __stdcall flush_file_buffers (HANDLE h) __attribute__ ((regparm (1))); +#define FlushFileBuffers flush_file_buffers /**************************** Exports ******************************/