Re: [PATCH] Cygwin: pty: Make system_printf() work after closing pty slave.

2020-05-21 Thread Takashi Yano via Cygwin-patches
On Wed, 20 May 2020 17:46:11 +0900
Takashi Yano via Cygwin-patches  wrote:
> On Tue, 19 May 2020 15:04:24 -0400
> Ken Brown via Cygwin-patches  wrote:
> > Hi Takashi,
> > 
> > On 5/19/2020 7:35 AM, Takashi Yano via Cygwin-patches wrote:
> > > - Current pty cannot show system_printf() output after closing pty
> > >slave. This patch fixes the issue.
> > 
> > Sorry to be returning the favor so soon, but this patch causes 'make check' 
> > in 
> > the texinfo source tree to hang.  I don't have time at the moment to try to 
> > produce a simple test case, so here's a complicated way to reproduce the 
> > problem:
> > 
> > 1. Clone the texinfo git repo:
> > 
> >$ git clone https://git.savannah.gnu.org/git/texinfo.git
> > 
> > 2. Build texinfo:
> > 
> >$ cd texinfo
> >$ ./autogen.sh && ./configure # Maybe CFLAGS='-g -O0' for debugging
> >$ make
> > 
> > 3. Test the standalone info reader:
> > 
> >$ cd info
> >$ make check
> > 
> > It hangs while running the test t/malformed-split.sh, leaving a ginfo 
> > process 
> > and a pseudotty process running, with ginfo trying to close a pty slave.
> > 
> > Note that this test uses both ptys and fifos, so there's always a chance 
> > that 
> > this is another fifo bug.  But reverting your patch fixes the problem, so I 
> > think it's probably a pty bug.
> 
> Sorry for inconvenience. I can reproduce your problem.
> I will check what is happening. Please wait a while. 

I found the cause. If pty master is closed, wait_pcon_fwd()
stucks because pty_master_fwd_thread is not running.

I will submit a patch to fix this issue soon.

-- 
Takashi Yano 


Re: [PATCH] Cygwin: pty: Make system_printf() work after closing pty slave.

2020-05-20 Thread Takashi Yano via Cygwin-patches
On Tue, 19 May 2020 15:04:24 -0400
Ken Brown via Cygwin-patches  wrote:
> Hi Takashi,
> 
> On 5/19/2020 7:35 AM, Takashi Yano via Cygwin-patches wrote:
> > - Current pty cannot show system_printf() output after closing pty
> >slave. This patch fixes the issue.
> 
> Sorry to be returning the favor so soon, but this patch causes 'make check' 
> in 
> the texinfo source tree to hang.  I don't have time at the moment to try to 
> produce a simple test case, so here's a complicated way to reproduce the 
> problem:
> 
> 1. Clone the texinfo git repo:
> 
>$ git clone https://git.savannah.gnu.org/git/texinfo.git
> 
> 2. Build texinfo:
> 
>$ cd texinfo
>$ ./autogen.sh && ./configure # Maybe CFLAGS='-g -O0' for debugging
>$ make
> 
> 3. Test the standalone info reader:
> 
>$ cd info
>$ make check
> 
> It hangs while running the test t/malformed-split.sh, leaving a ginfo process 
> and a pseudotty process running, with ginfo trying to close a pty slave.
> 
> Note that this test uses both ptys and fifos, so there's always a chance that 
> this is another fifo bug.  But reverting your patch fixes the problem, so I 
> think it's probably a pty bug.

Sorry for inconvenience. I can reproduce your problem.
I will check what is happening. Please wait a while. 

-- 
Takashi Yano 


Re: [PATCH] Cygwin: pty: Make system_printf() work after closing pty slave.

2020-05-19 Thread Ken Brown via Cygwin-patches

Hi Takashi,

On 5/19/2020 7:35 AM, Takashi Yano via Cygwin-patches wrote:

- Current pty cannot show system_printf() output after closing pty
   slave. This patch fixes the issue.


Sorry to be returning the favor so soon, but this patch causes 'make check' in 
the texinfo source tree to hang.  I don't have time at the moment to try to 
produce a simple test case, so here's a complicated way to reproduce the problem:


1. Clone the texinfo git repo:

  $ git clone https://git.savannah.gnu.org/git/texinfo.git

2. Build texinfo:

  $ cd texinfo
  $ ./autogen.sh && ./configure # Maybe CFLAGS='-g -O0' for debugging
  $ make

3. Test the standalone info reader:

  $ cd info
  $ make check

It hangs while running the test t/malformed-split.sh, leaving a ginfo process 
and a pseudotty process running, with ginfo trying to close a pty slave.


Note that this test uses both ptys and fifos, so there's always a chance that 
this is another fifo bug.  But reverting your patch fixes the problem, so I 
think it's probably a pty bug.


Ken


Re: [PATCH] Cygwin: pty: Make system_printf() work after closing pty slave.

2020-05-19 Thread Corinna Vinschen
On May 19 20:35, Takashi Yano via Cygwin-patches wrote:
> - Current pty cannot show system_printf() output after closing pty
>   slave. This patch fixes the issue.
> ---
>  winsup/cygwin/fhandler_tty.cc | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
> index 5a1bcd3ce..02b78cd2c 100644
> --- a/winsup/cygwin/fhandler_tty.cc
> +++ b/winsup/cygwin/fhandler_tty.cc
> @@ -948,6 +948,10 @@ fhandler_pty_slave::open (int flags, mode_t)
>init_console_handler (true);
>  }
>  
> +  get_ttyp ()->pcon_pid = 0;
> +  get_ttyp ()->switch_to_pcon_in = false;
> +  get_ttyp ()->switch_to_pcon_out = false;
> +
>set_open_status ();
>return 1;
>  
> @@ -1008,6 +1012,7 @@ fhandler_pty_slave::close ()
>  termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex);
>if (pcon_attached_to == get_minor ())
>  get_ttyp ()->num_pcon_attached_slaves --;
> +  set_switch_to_pcon (2); /* Make system_printf() work after close. */
>return 0;
>  }
>  
> -- 
> 2.21.0

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


[PATCH] Cygwin: pty: Make system_printf() work after closing pty slave.

2020-05-19 Thread Takashi Yano via Cygwin-patches
- Current pty cannot show system_printf() output after closing pty
  slave. This patch fixes the issue.
---
 winsup/cygwin/fhandler_tty.cc | 5 +
 1 file changed, 5 insertions(+)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 5a1bcd3ce..02b78cd2c 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -948,6 +948,10 @@ fhandler_pty_slave::open (int flags, mode_t)
   init_console_handler (true);
 }
 
+  get_ttyp ()->pcon_pid = 0;
+  get_ttyp ()->switch_to_pcon_in = false;
+  get_ttyp ()->switch_to_pcon_out = false;
+
   set_open_status ();
   return 1;
 
@@ -1008,6 +1012,7 @@ fhandler_pty_slave::close ()
 termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex);
   if (pcon_attached_to == get_minor ())
 get_ttyp ()->num_pcon_attached_slaves --;
+  set_switch_to_pcon (2); /* Make system_printf() work after close. */
   return 0;
 }
 
-- 
2.21.0