]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Close pseudo console only if the process is the owner.
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Sat, 9 Apr 2022 03:59:54 +0000 (12:59 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Sat, 9 Apr 2022 03:59:54 +0000 (12:59 +0900)
- Currently, close_pseudoconsole() is called unconditionally from
  fhandler_termios::process_sigs() on Ctrl-C. This causes deadlock
  if Ctrl-C is pressed while setup_pseudoconsole() is called. With
  this patch, close_pseudoconsole() is called only if the master
  process is the owner of the nat-pipe to avoid the deadlock.

winsup/cygwin/fhandler_tty.cc

index 4cb5f1411bbee113404fba873f30da7534d2e78c..c02dfb8edbb49fb56571270bee1b6257d03eacd1 100644 (file)
@@ -4152,7 +4152,8 @@ void
 fhandler_pty_slave::release_ownership_of_nat_pipe (tty *ttyp,
                                                   fhandler_termios *fh)
 {
-  if (fh->get_major () == DEV_PTYM_MAJOR)
+  if (fh->get_major () == DEV_PTYM_MAJOR
+      && nat_pipe_owner_self (ttyp->nat_pipe_owner_pid))
     {
       fhandler_pty_master *ptym = (fhandler_pty_master *) fh;
       WaitForSingleObject (ptym->pipe_sw_mutex, INFINITE);
This page took 0.034191 seconds and 5 git commands to generate.