aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-05-09 14:10:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-05-09 14:10:20 +0200
commite03c638d0d0bd2ab50940bc479cb5b7ff18c9803 (patch)
treeea65ab30e94230ecae6784157e064afd6371d883
parentfd9543ece42a8a9071f38fc661d246b17e44db7e (diff)
Fix fdterm() mis-classification of nul on Windows with GetConsoleMode() call
-rw-r--r--libbutl/fdstream.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/libbutl/fdstream.cxx b/libbutl/fdstream.cxx
index 07cb9f2..df5b531 100644
--- a/libbutl/fdstream.cxx
+++ b/libbutl/fdstream.cxx
@@ -1889,7 +1889,13 @@ namespace butl
throw_system_ios_failure (e);
if (t == FILE_TYPE_CHAR) // Terminal.
- return true;
+ {
+ // One notable special file that has this type is nul (as returned by
+ // fdopen_null()). So tighten this case with the GetConsoleMode() call.
+ //
+ DWORD m;
+ return GetConsoleMode (h, &m) != 0;
+ }
if (t != FILE_TYPE_PIPE) // Pipe still can be a terminal (see below).
return false;