summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-10-17 14:26:28 +0200
committerWerner Koch <wk@gnupg.org>2021-10-20 16:40:14 +0200
commite293da3b214958ff86e7636d17b0b6e10264882e (patch)
treea995ef1df5de7031195b23a730ca2ae0fad9f893
parentdns: Make reading resolv.conf more robust. (diff)
downloadgnupg2-e293da3b214958ff86e7636d17b0b6e10264882e.tar.xz
gnupg2-e293da3b214958ff86e7636d17b0b6e10264882e.zip
common,w32: Do not always print "Garbled console data" warning.
* common/init.c (_init_common_subsystems): Silence message. --
-rw-r--r--common/init.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/common/init.c b/common/init.c
index 7b6b4aea0..7d4119268 100644
--- a/common/init.c
+++ b/common/init.c
@@ -208,8 +208,14 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp)
gettext_use_utf8 (1);
if (!SetConsoleCP (CP_UTF8) || !SetConsoleOutputCP (CP_UTF8))
{
- log_info ("SetConsoleCP failed: %s\n", w32_strerror (-1));
- log_info ("Warning: Garbled console data possible\n");
+ /* Don't show the error if the program does not have a console.
+ * This is for example the case for daemons. */
+ in rc = GetLastError ();
+ if (rc != ERROR_INVALID_HANDLE)
+ {
+ log_info ("SetConsoleCP failed: %s\n", w32_strerror (rc));
+ log_info ("Warning: Garbled console data possible\n");
+ }
}
#endif