[newlib-cygwin] Cygwin: pty: Avoid detach console in the process running as service.

2019-10-17 Thread Ken Brown
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9bedd6807dc3a1ad6c80e62a6a7aae27ca769de0

commit 9bedd6807dc3a1ad6c80e62a6a7aae27ca769de0
Author: Takashi Yano 
Date:   Wed Oct 16 21:34:08 2019 +0900

Cygwin: pty: Avoid detach console in the process running as service.

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 1095c82..dbb035f 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1048,6 +1048,8 @@ fhandler_pty_slave::try_reattach_pcon (void)
 
   /* Do not detach from the console because re-attaching will
  fail if helper process is running as service account. */
+  if (get_ttyp()->attach_pcon_in_fork)
+return false;
   if (pcon_attached_to >= 0 &&
   cygwin_shared->tty[pcon_attached_to]->attach_pcon_in_fork)
 return false;


[newlib-cygwin] Cygwin: pty: Change the timing of clear screen.

2019-10-17 Thread Ken Brown
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=43d7f33e2cab414a9f42a03b3347bc41e029dbbc

commit 43d7f33e2cab414a9f42a03b3347bc41e029dbbc
Author: Takashi Yano 
Date:   Wed Oct 16 21:34:09 2019 +0900

Cygwin: pty: Change the timing of clear screen.

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index dbb035f..da6119d 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2716,6 +2716,19 @@ fhandler_pty_slave::fixup_after_fork (HANDLE parent)
   // fork_fixup (parent, inuse, "inuse");
   // fhandler_pty_common::fixup_after_fork (parent);
   report_tty_counts (this, "inherited", "");
+
+  if (get_ttyp ()->need_clear_screen)
+{
+  const char *term = getenv ("TERM");
+  if (term && strcmp (term, "dumb") && !strstr (term, "emacs"))
+   {
+ /* FIXME: Clearing sequence may not be "^[[H^[[J"
+depending on the terminal type. */
+ DWORD n;
+ WriteFile (get_output_handle_cyg (), "\033[H\033[J", 6, &n, NULL);
+   }
+  get_ttyp ()->need_clear_screen = false;
+}
 }
 
 void
@@ -2759,19 +2772,6 @@ fhandler_pty_slave::fixup_after_exec ()
}
 }
 
-  if (get_ttyp ()->need_clear_screen)
-{
-  const char *term = getenv ("TERM");
-  if (term && strcmp (term, "dumb") && !strstr (term, "emacs"))
-   {
- /* FIXME: Clearing sequence may not be "^[[H^[[J"
-depending on the terminal type. */
- DWORD n;
- WriteFile (get_output_handle_cyg (), "\033[H\033[J", 6, &n, NULL);
-   }
-  get_ttyp ()->need_clear_screen = false;
-}
-
   /* Set locale */
   setup_locale ();