aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/asshelp.c1
-rw-r--r--common/homedir.c23
-rw-r--r--common/util.h7
3 files changed, 30 insertions, 1 deletions
diff --git a/common/asshelp.c b/common/asshelp.c
index a45f05714..659f35dbe 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -540,6 +540,7 @@ start_new_service (assuan_context_t *r_ctx,
err = gpgrt_process_spawn (program? program : program_name, argv,
(GPGRT_PROCESS_DETACHED
+ |GPGRT_PROCESS_STDIO_NUL
|GPGRT_PROCESS_STDOUT_PIPE
|GPGRT_PROCESS_STDERR_KEEP),
NULL, &proc);
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*/
diff --git a/common/util.h b/common/util.h
index 3a5f086f9..0ab779ad1 100644
--- a/common/util.h
+++ b/common/util.h
@@ -240,6 +240,12 @@ const char *get_keyalgo_string (enum gcry_pk_algos algo,
/*-- homedir.c --*/
+#ifdef HAVE_W32_SYSTEM
+int gnupg_isatty (int fd);
+#else
+#define gnupg_isatty(a) isatty ((a))
+#endif
+
const char *standard_homedir (void);
void gnupg_set_homedir (const char *newdir);
void gnupg_maybe_make_homedir (const char *fname, int quiet);
@@ -427,7 +433,6 @@ _gnupg_ttyname (int fd)
# define gnupg_ttyname(n) ttyname ((n))
#endif /*HAVE_TTYNAME */
-#define gnupg_isatty(a) isatty ((a))
/*-- Macros to replace ctype ones to avoid locale problems. --*/