From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 9CAE93858D39; Tue, 7 Mar 2023 02:38:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CAE93858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678156711; bh=mui5Wf75nAwiY1M0ZeQ6yRRJIs4WvAm3kVOGlVpsChY=; h=From:To:Subject:Date:From; b=Zb47FFREiTtjrkbSgydMQnfgo6lHePkmEeN9P8eZkwL0Gw8HbzatJoyOScmZ2a9Hl MkToLX9TcNYUXfqeBLwIGGXd4u/2vJy00Q3RAPkm1VyrsXIJ11SIW6VkbfsaSg4Cbz yi2aLh2AoVUNemFm1C4sMQjREbcN+A8TTp6c19ZA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: ctty: Add missing fixup_after_{exec,fork}() call. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: 77f324ae03547c82b724ef5a35bd72b2ecf09e61 X-Git-Newrev: 8d0b9ab672eccdb5421324435494e6f3cf7b3882 Message-Id: <20230307023831.9CAE93858D39@sourceware.org> Date: Tue, 7 Mar 2023 02:38:31 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D8d0b9ab672e= ccdb5421324435494e6f3cf7b3882 commit 8d0b9ab672eccdb5421324435494e6f3cf7b3882 Author: Takashi Yano Date: Tue Mar 7 00:13:55 2023 +0900 Cygwin: ctty: Add missing fixup_after_{exec,fork}() call. =20 Previously, fixup_after_{exec,fork}() calls for CTTY were missing. This patch fixes that. =20 Signed-off-by: Takashi Yano 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 <=3D 2) SetStdHandle (std_consts[i], fh->get_output_handle ()); } + if (cygheap->ctty) + cygheap->ctty->fixup_after_exec (); } =20 void @@ -939,6 +941,9 @@ dtable::fixup_after_fork (HANDLE parent) else if (i <=3D 2) SetStdHandle (std_consts[i], fh->get_output_handle ()); } + + if (cygheap->ctty) + cygheap->ctty->fixup_after_fork (parent); } =20 static void diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/con= sole.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 =3D NULL; set_handle (NULL); set_output_handle (NULL); created =3D false; @@ -4046,6 +4047,12 @@ fhandler_console::fixup_after_fork_exec (bool execin= g) set_unit (); setup_io_mutex (); wpbuf.init (get_output_handle ()); + if (cygheap->ctty =3D=3D this && !get_handle () && !get_output_handle ()) + { + close_with_arch (); + cygheap->ctty =3D NULL; + return; + } =20 if (!execing) return;