Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-12-26 22:34:59 +0300
committerChristopher Faylor <me@cgf.cx>2005-12-26 22:34:59 +0300
commita16b738dd53486a3a65a28519129ebd060a02db9 (patch)
tree997fdb3185d3f3e8e83524e53a7578bd63aef357 /winsup/cygwin/strace.cc
parentc675040a068e107e8628b8e29efd975b1162dc66 (diff)
* dcrt0.cc (__api_fatal): Simplify to just use strace mechamisms.
(do_exit): Move minimal_printf... * pinfo.cc (pinfo::exit): ...into here. * strace.cc (strace::vprntf): Guarantee output to the console when system_printf/api_fatal. * heap.cc (heap_init): Wait a second before issuing an error when ERROR_INVALID_ADDRESS since this is probably due to a CTRL-C handler sneaking in, using the memory that we want to use for the heap, and, eventually exiting.
Diffstat (limited to 'winsup/cygwin/strace.cc')
-rw-r--r--winsup/cygwin/strace.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index 54fab722a..6634a68dd 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -202,24 +202,35 @@ void
strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap)
{
DWORD err = GetLastError ();
- int count;
+ int len;
char buf[10000];
PROTECT (buf);
SetLastError (err);
- count = vsprntf (buf, func, fmt, ap);
+ len = vsprntf (buf, func, fmt, ap);
CHECK (buf);
if (category & _STRACE_SYSTEM)
{
DWORD done;
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, 0);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, len, &done, 0);
FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE));
+ /* Make sure that the message shows up on the screen, too, since this is
+ a serious error. */
+ if (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) != FILE_TYPE_CHAR)
+ {
+ HANDLE h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_WRITE | FILE_SHARE_WRITE,
+ &sec_none, OPEN_EXISTING, 0, 0);
+ if (h != INVALID_HANDLE_VALUE)
+ WriteFile (h, buf, len, &done, 0);
+ CloseHandle (h);
+ }
}
#ifndef NOSTRACE
if (active)
- write (category, buf, count);
+ write (category, buf, len);
#endif
SetLastError (err);
}