Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/ChangeLog,v
retrieving revision 1.6671
diff -u -p -r1.6671 ChangeLog
--- ChangeLog	5 Mar 2015 13:58:02 -0000	1.6671
+++ ChangeLog	7 Mar 2015 22:46:36 -0000
@@ -1,3 +1,8 @@
+2015-03-08  Takashi Yano <takashi.yano@nifty.ne.jp>
+
+	* fhandler_tty.cc (fhandler_pty_master::close): Add code to make slave
+	detect closure of master. Fix typo in error message.
+
 2015-03-05  Corinna Vinschen  <corinna@vinschen.de>
 
 	* tty.h (tty::set_master_ctl_closed): Rename from set_master_closed.
Index: fhandler_tty.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v
retrieving revision 1.292
diff -u -p -r1.292 fhandler_tty.cc
--- fhandler_tty.cc	5 Mar 2015 13:58:02 -0000	1.292
+++ fhandler_tty.cc	7 Mar 2015 22:46:36 -0000
@@ -1317,17 +1317,21 @@ fhandler_pty_master::close ()
 	}
     }
 
+  fhandler_pty_common::close ();
+
+  if (!PeekNamedPipe (from_master, NULL, 0, NULL, NULL, NULL)
+      && GetLastError () == ERROR_BROKEN_PIPE) 
+    SetEvent (input_available_event);
+
   if (!ForceCloseHandle (from_master))
     termios_printf ("error closing from_master %p, %E", from_master);
   if (!ForceCloseHandle (to_master))
-    termios_printf ("error closing from_master %p, %E", to_master);
+    termios_printf ("error closing to_master %p, %E", to_master);
   from_master = to_master = NULL;
   ForceCloseHandle (echo_r);
   ForceCloseHandle (echo_w);
   echo_r = echo_w = NULL;
 
-  fhandler_pty_common::close ();
-
   if (have_execed || get_ttyp ()->master_pid != myself->pid)
     termios_printf ("not clearing: %d, master_pid %d", have_execed, get_ttyp ()->master_pid);
   if (!ForceCloseHandle (input_available_event))
