summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2015-03-12 15:48:10 +0100
committerCorinna Vinschen <corinna@vinschen.de>2015-03-12 15:48:10 +0100
commit32fd5b0fe1548cff79b9868e4e259853c59a44db (patch)
tree2d6996fe598d7a4b99771b7c7ee9652dc3de4ef1 /winsup/cygwin/fhandler_tty.cc
parenta34ebbad281ad985a2f2e933c23bfbef41ec2d4c (diff)
downloadcygnal-32fd5b0fe1548cff79b9868e4e259853c59a44db.tar.gz
cygnal-32fd5b0fe1548cff79b9868e4e259853c59a44db.tar.bz2
cygnal-32fd5b0fe1548cff79b9868e4e259853c59a44db.zip
Let pty slave detect closure of last master handle
* fhandler_tty.cc (fhandler_pty_master::close): Add code to make slave detect closure of master. Fix typo in error message. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index c7c90e28d..87bd6a0aa 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1317,17 +1317,23 @@ fhandler_pty_master::close ()
}
}
+ fhandler_pty_common::close ();
+
+ /* Check if the last master handle has been closed. If so, set
+ input_available_event to wake up potentially waiting slaves. */
+ 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))