diff options
| author | Kevin Koch <kpkoch@mit.edu> | 2007-03-27 17:27:41 +0000 |
|---|---|---|
| committer | Kevin Koch <kpkoch@mit.edu> | 2007-03-27 17:27:41 +0000 |
| commit | ebe7571630540b34875ff9b916b6ebd2c6450324 (patch) | |
| tree | 9369190b11834bf696363140d2c3378639a1d77e /src/util/et | |
| parent | 660521f6a7e4e48e514188f4d25e13c8a56d3afc (diff) | |
| download | krb5-ebe7571630540b34875ff9b916b6ebd2c6450324.tar.gz krb5-ebe7571630540b34875ff9b916b6ebd2c6450324.tar.xz krb5-ebe7571630540b34875ff9b916b6ebd2c6450324.zip | |
All Windows apps were popping MessageBoxes when stderr is redirected. Console apps shouldn't and no longer do that. Added isGuiApp, which tests gui resource usage
Removed duplicate nested tests for _WIN32.
Ticket: 5446
Status: resolved
Target_Version: 1.6.1
Tags: pullup
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19292 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/et')
| -rw-r--r-- | src/util/et/com_err.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c index 5a274d2c1..c759e17b6 100644 --- a/src/util/et/com_err.c +++ b/src/util/et/com_err.c @@ -33,6 +33,16 @@ static /*@null@*/ et_old_error_hook_func com_err_hook = 0; k5_mutex_t com_err_hook_lock = K5_MUTEX_PARTIAL_INITIALIZER; +#if defined(_WIN32) +BOOL isGuiApp() { + DWORD mypid; + HANDLE myprocess; + mypid = GetCurrentProcessId(); + myprocess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, mypid); + return GetGuiResources(myprocess, 1) > 0; + } +#endif + static void default_com_err_proc (const char *whoami, errcode_t code, const char *fmt, va_list ap) { @@ -55,14 +65,12 @@ static void default_com_err_proc (const char *whoami, errcode_t code, vsprintf (errbuf + strlen (errbuf), fmt, ap); errbuf[sizeof(errbuf) - 1] = '\0'; -#ifdef _WIN32 - if (_isatty(_fileno(stderr))) { + if (_isatty(_fileno(stderr)) || !isGuiApp()) { fputs(errbuf, stderr); fputc('\r', stderr); fputc('\n', stderr); fflush(stderr); } else -#endif /* _WIN32 */ MessageBox ((HWND)NULL, errbuf, "Kerberos", MB_ICONEXCLAMATION); #else /* !_WIN32 */ |
