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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Takashi Yano
---
 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 baf3c9794..da6119dfb 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;
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

[PATCH] Cygwin: pty: Change the timing of clear screen.

Takashi Yano
---
 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 1095c82eb..baf3c9794 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2714,6 +2714,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
@@ -2757,19 +2770,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 ();
 
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: pty: Change the timing of clear screen.

Ken Brown-6
On 10/16/2019 8:34 AM, Takashi Yano wrote:

> ---
>   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 1095c82eb..baf3c9794 100644
> --- a/winsup/cygwin/fhandler_tty.cc
> +++ b/winsup/cygwin/fhandler_tty.cc
> @@ -2714,6 +2714,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
> @@ -2757,19 +2770,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 ();

This and the previous patch look good to me, but we should probably wait
for Haubi to confirm that they fix the problems he reported.

Ken
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: pty: Change the timing of clear screen.

Michael Haubenwallner-2
On 10/17/19 4:55 PM, Ken Brown wrote:
> On 10/16/2019 8:34 AM, Takashi Yano wrote:
>> ---
>>   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 1095c82eb..baf3c9794 100644
>> --- a/winsup/cygwin/fhandler_tty.cc
>> +++ b/winsup/cygwin/fhandler_tty.cc

>
> This and the previous patch look good to me, but we should probably wait
> for Haubi to confirm that they fix the problems he reported.

I'm unsure what the first patch does address: It does not fix the 'ssh -t' testcase,
and I doubt it actually should.  But it doesn't seem to break anything here so far.

The second patch fixes the (minor) issue with the 'Last login' line as expected.

/haubi/
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: pty: Change the timing of clear screen.

Ken Brown-6
On 10/17/2019 12:03 PM, Michael Haubenwallner wrote:

> On 10/17/19 4:55 PM, Ken Brown wrote:
>> On 10/16/2019 8:34 AM, Takashi Yano wrote:
>>> ---
>>>    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 1095c82eb..baf3c9794 100644
>>> --- a/winsup/cygwin/fhandler_tty.cc
>>> +++ b/winsup/cygwin/fhandler_tty.cc
>
>>
>> This and the previous patch look good to me, but we should probably wait
>> for Haubi to confirm that they fix the problems he reported.
>
> I'm unsure what the first patch does address: It does not fix the 'ssh -t' testcase,
> and I doubt it actually should.  But it doesn't seem to break anything here so far.
>
> The second patch fixes the (minor) issue with the 'Last login' line as expected.

Thanks.  I'll go ahead and push both patches.  And thanks, Takashi.  (Or should
I be addressing you as "Yano"?  I'm ignorant about Japanese names.)

Ken
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: pty: Change the timing of clear screen.

Takashi Yano
On Thu, 17 Oct 2019 16:36:25 +0000
Ken Brown wrote:
> Thanks.  I'll go ahead and push both patches.  And thanks, Takashi.  (Or should
> I be addressing you as "Yano"?  I'm ignorant about Japanese names.)

Takashi is the given name and Yano is the family name.
In Japan, we usualy use the order of family-name first,
i.e. Yano Takashi. However, many of us use inversed order
when we talk with Western people.

In formal situation, we use family name with "san", i.e.
Yano-san, just like Mr. Yano. Contrary, given name is used
for close relationships.

So, please call me Takashi as always.

--
Takashi Yano <[hidden email]>