Index: fhandler_tty.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v retrieving revision 1.29 diff -u -p -2 -r1.29 fhandler_tty.cc --- fhandler_tty.cc 2001/03/18 18:05:01 1.29 +++ fhandler_tty.cc 2001/03/19 17:32:43 @@ -62,4 +62,6 @@ fhandler_tty_master::init (int ntty) cygwin_shared->tty[ttynum]->common_init (this); + inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE, FALSE); + h = makethread (process_input, NULL, 0, "ttyin"); if (h == NULL) @@ -483,5 +485,5 @@ fhandler_tty_slave::open (const char *, { acquire_output_mutex (500); - inuse = get_ttyp ()->create_inuse (TTY_SLAVE_ALIVE); + inuse = get_ttyp ()->create_inuse (TTY_SLAVE_ALIVE, TRUE); get_ttyp ()->was_opened = TRUE; release_output_mutex (); @@ -948,5 +950,5 @@ fhandler_pty_master::open (const char *, cygwin_shared->tty[ttynum]->common_init (this); - inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE); + inuse = get_ttyp ()->create_inuse (TTY_MASTER_ALIVE, FALSE); set_flags (flags); @@ -970,4 +972,12 @@ fhandler_tty_common::close () if (!ForceCloseHandle (input_mutex)) termios_printf ("CloseHandle (input_mutex<%p>), %E", input_mutex); + + /* Send EOF to slaves if master side is closed */ + if (!get_ttyp ()->master_alive ()) + { + termios_printf ("no more masters left. sending EOF" ); + SetEvent (input_available_event); + } + if (!ForceCloseHandle (input_available_event)) termios_printf ("CloseHandle (input_available_event<%p>), %E", input_available_event); Index: tty.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/tty.cc,v retrieving revision 1.17 diff -u -p -2 -r1.17 tty.cc --- tty.cc 2001/03/18 21:11:25 1.17 +++ tty.cc 2001/03/19 17:32:43 @@ -139,4 +139,5 @@ tty_list::terminate (void) ForceCloseHandle1 (t->to_slave, to_pty); ForceCloseHandle1 (t->from_slave, from_pty); + CloseHandle (tty_master->inuse); WaitForSingleObject (tty_master->hThread, INFINITE); t->init (); @@ -300,5 +301,5 @@ tty::alive (const char *fmt) HANDLE -tty::create_inuse (const char *fmt) +tty::create_inuse (const char *fmt, BOOL inherit) { HANDLE h; @@ -306,5 +307,5 @@ tty::create_inuse (const char *fmt) __small_sprintf (buf, fmt, ntty); - h = CreateEvent (&sec_all, TRUE, FALSE, buf); + h = CreateEvent ((inherit ? &sec_all : &sec_all_nih), TRUE, FALSE, buf); termios_printf ("%s = %p", buf, h); if (!h) Index: tty.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/tty.h,v retrieving revision 1.4 diff -u -p -2 -r1.4 tty.h --- tty.h 2001/03/18 18:05:01 1.4 +++ tty.h 2001/03/19 17:32:43 @@ -100,5 +100,5 @@ public: void init (); - HANDLE create_inuse (const char *); + HANDLE create_inuse (const char *, BOOL); BOOL common_init (fhandler_pty_master *); BOOL alive (const char *fmt);