Skip to content

Commit

Permalink
ticket: 5446
Browse files Browse the repository at this point in the history
version_fixed: 1.6.1

pull up r19292 from trunk

 r19292@cathode-dark-space:  kpkoch | 2007-03-27 13:27:41 -0400
 Ticket: 5446
 Status: resolved
 Target_Version: 1.6.1
 Tags:  pullup
 
 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.



git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19343 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information
tlyu committed Mar 30, 2007
1 parent db17e14 commit 2811122
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/util/et/com_err.c
Expand Up @@ -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)
{
Expand All @@ -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 */
Expand Down

0 comments on commit 2811122

Please sign in to comment.