From: ian AT cygnus DOT com (Ian Lance Taylor) Subject: Re: Compatibility function for cygwin and a telnet problem 17 Feb 1998 09:06:46 -0800 Message-ID: <199802171700.MAA29212.cygnus.cygwin32.developers@subrogation.cygnus.com> References: <01BD3BBD DOT B44B1880 AT gater DOT krystalbank DOT msk DOT ru> Reply-To: cygwin32-developers AT cygnus DOT com To: sos AT prospect DOT com DOT ru Cc: cygwin32-developers AT cygnus DOT com From: Sergey Okhapkin Date: Tue, 17 Feb 1998 16:04:14 +0300 Ian Lance Taylor wrote: > OK, I give up on making the pipe read work correctly. I changed > do_output to loop using PeekNamedPipe and check whether the pipe had > been closed. > > Please try this patch. No luck - process_output thread in tty master exits on process startup because no tty slaves are connected at this time. Please try this patch. I don't have a way to test it, so I don't know whether it will work. Ian Index: tty.cc =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/tty.cc,v retrieving revision 1.6.8.1.4.13 diff -u -r1.6.8.1.4.13 tty.cc --- tty.cc 1998/02/17 16:45:32 1.6.8.1.4.13 +++ tty.cc 1998/02/17 17:00:03 @@ -351,6 +351,7 @@ /* Save our pid */ ttyp->master_pid = GetCurrentProcessId (); + ttyp->slave_opened = 0; /* Allow the others to open us (for handle duplication) */ @@ -697,14 +698,16 @@ __seterrno (); return -1; } - termios_printf ("%u available; %d handles\n", (int) avail, - s->t.getcount (m->ttynum)); + termios_printf ("%u available; %d handles; slave %sopened\n", + (int) avail, s->t.getcount (m->ttynum), + ttyp->slave_opened ? "" : "not "); if (avail > 0) break; - if (s->t.getcount (m->ttynum) == 1) + if (s->t.getcount (m->ttynum) == 1 && ttyp->slave_opened) { - /* We have the only remaining open handle to this pty, which - we treat as EOF. */ + /* We have the only remaining open handle to this pty, and + the slave pty has been opened at least once. We treat + this as EOF. */ termios_printf ("all other handles closed\n"); return 0; } @@ -938,6 +941,8 @@ } CloseHandle (handle_owner); + ttyp->slave_opened = 1; + termios_printf("tty%d opened\n", ttynum); return this; @@ -1496,6 +1501,7 @@ /* Save our pid */ ttyp->master_pid = GetCurrentProcessId (); + ttyp->slave_opened = 0; /* Allow the others to open us (for handle duplication) */ Index: tty.h =================================================================== RCS file: /cvs/cvsfiles/devo/winsup/tty.h,v retrieving revision 1.4.14.5 diff -u -r1.4.14.5 tty.h --- tty.h 1998/02/16 20:45:10 1.4.14.5 +++ tty.h 1998/02/17 17:00:03 @@ -53,6 +53,7 @@ HWND hwnd; /* Console window handle tty belongs to */ DWORD master_pid; /* Win32 PID of tty master process */ + int slave_opened; HANDLE input_handle; /* Real I/O handles of master tty */ HANDLE output_handle;