aboutsummaryrefslogtreecommitdiffstats
path: root/common/homedir.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/homedir.c')
-rw-r--r--common/homedir.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/common/homedir.c b/common/homedir.c
index d26ddd902..8622b459c 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -987,6 +987,29 @@ w32_commondir (void)
return dir;
}
+
+/*
+ * On Windows, isatty returns TRUE when it's NUL device.
+ * We need more checks.
+ */
+int
+gnupg_isatty (int fd)
+{
+ HANDLE h;
+ DWORD mode;
+
+ if (!isatty (fd))
+ return 0;
+
+ h = (HANDLE)_get_osfhandle (fd);
+ if (h == INVALID_HANDLE_VALUE)
+ return 0;
+
+ if (!GetConsoleMode (h, &mode))
+ return 0;
+
+ return 1;
+}
#endif /*HAVE_W32_SYSTEM*/