summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/miscfuncs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r--winsup/cygwin/miscfuncs.cc11
1 files changed, 11 insertions, 0 deletions
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;
+}