[newlib-cygwin/cygwin-3_4-branch] Cygwin: ctty: Add missing fixup_after_{exec, fork}() call.

Takashi Yano tyan0@sourceware.org
Tue Mar 7 02:38:31 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8d0b9ab672eccdb5421324435494e6f3cf7b3882

commit 8d0b9ab672eccdb5421324435494e6f3cf7b3882
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Tue Mar 7 00:13:55 2023 +0900

    Cygwin: ctty: Add missing fixup_after_{exec,fork}() call.
    
    Previously, fixup_after_{exec,fork}() calls for CTTY were missing.
    This patch fixes that.
    
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/dtable.cc           | 5 +++++
 winsup/cygwin/fhandler/console.cc | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 6b2394814..8ebd7b211 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -913,6 +913,8 @@ dtable::fixup_after_exec ()
 	else if (i <= 2)
 	  SetStdHandle (std_consts[i], fh->get_output_handle ());
       }
+  if (cygheap->ctty)
+    cygheap->ctty->fixup_after_exec ();
 }
 
 void
@@ -939,6 +941,9 @@ dtable::fixup_after_fork (HANDLE parent)
 	else if (i <= 2)
 	  SetStdHandle (std_consts[i], fh->get_output_handle ());
       }
+
+  if (cygheap->ctty)
+    cygheap->ctty->fixup_after_fork (parent);
 }
 
 static void
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index a30b5416e..c9b27c9c5 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -622,6 +622,7 @@ fhandler_console::set_unit ()
     pc.file_attributes (FILE_ATTRIBUTE_NORMAL);
   else
     {
+      _tc = NULL;
       set_handle (NULL);
       set_output_handle (NULL);
       created = false;
@@ -4046,6 +4047,12 @@ fhandler_console::fixup_after_fork_exec (bool execing)
   set_unit ();
   setup_io_mutex ();
   wpbuf.init (get_output_handle ());
+  if (cygheap->ctty == this && !get_handle () && !get_output_handle ())
+    {
+      close_with_arch ();
+      cygheap->ctty = NULL;
+      return;
+    }
 
   if (!execing)
     return;


More information about the Cygwin-cvs mailing list