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:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2019-09-04 16:46:51 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-09-04 16:59:38 +0300
commit83b2d576c835dad6b8e2ea53b55a25e7bfcdcde7 (patch)
tree7a2158834e99d25b26fb86e1eb9a84a7b6a13b1c /winsup/cygwin/strace.cc
parent583102e7c9255ae25310154995f855e4f573f81c (diff)
Cygwin: pty: Limit API hook to the program linked with the APIs.
- API hook used for pseudo console support causes slow down. This patch limits API hook to only program which is linked with the corresponding APIs. Normal cygwin program is not linked with such APIs (such as WriteFile, etc...) directly, therefore, no slow down occurs. However, console access by cygwin.dll itself cannot switch the r/w pipe to pseudo console side. Therefore, the code to switch it forcely to pseudo console side is added to smallprint.cc and strace.cc.
Diffstat (limited to 'winsup/cygwin/strace.cc')
-rw-r--r--winsup/cygwin/strace.cc26
1 files changed, 2 insertions, 24 deletions
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index b1eb5f3e4..f0aef3a36 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -264,6 +264,7 @@ strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap
if (category & _STRACE_SYSTEM)
{
DWORD done;
+ set_ishybrid_and_switch_to_pcon (GetStdHandle (STD_ERROR_HANDLE));
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
@@ -275,34 +276,11 @@ strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap
&sec_none, OPEN_EXISTING, 0, 0);
if (h != INVALID_HANDLE_VALUE)
{
+ set_ishybrid_and_switch_to_pcon (h);
WriteFile (h, buf, len, &done, 0);
CloseHandle (h);
}
}
-#if 1 /* Experimental code */
- /* PTY with pseudo console cannot display data written to
- STD_ERROR_HANDLE (output_handle) if the process is cygwin
- process. output_handle works only in native console apps.
- Therefore the data should be written to output_handle_cyg
- as well. */
- fhandler_base *fh = ::cygheap->fdtab[2];
- if (fh && fh->get_major () == DEV_PTYS_MAJOR)
- {
- fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
- if (ptys->getPseudoConsole ())
- {
- HANDLE h_cyg = ptys->get_output_handle_cyg ();
- if (buf[len-1] == '\n' && len < NT_MAX_PATH - 1)
- {
- buf[len-1] = '\r';
- buf[len] = '\n';
- len ++;
- }
- WriteFile (h_cyg, buf, len, &done, 0);
- FlushFileBuffers (h_cyg);
- }
- }
-#endif
}
#ifndef NOSTRACE