From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 9E7B13858D39; Tue, 7 Mar 2023 02:38:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E7B13858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678156680; bh=Ti8GgwZ7lbYU/qpJYDro5bggJ5oUheh4h1iT2kn+r7o=; h=From:To:Subject:Date:From; b=aqs9WiwSaeYHL/f9W0Ww5OHKMusMGMr0an1vjchdczSw3Tjw3SqLh7bB2bnxmAHtY IEhg3QdpUoD/GS2iPyDmdEAg7g+JpIM+pPIDXo5NBdDjxwK+TQwBA3WIA8y3FffRIh +Jy2Md26mJR4ILPDJuVPtY3U6FITlJrnDA6X2XUs= 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: ctty: Add missing fixup_after_{exec,fork}() call. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 5ca1c57a82e040cf98cd8468d806b398d019ddbe X-Git-Newrev: 523985b31e5ed6318705a30525716187d758bc2f Message-Id: <20230307023800.9E7B13858D39@sourceware.org> Date: Tue, 7 Mar 2023 02:38:00 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D523985b31e5= ed6318705a30525716187d758bc2f commit 523985b31e5ed6318705a30525716187d758bc2f 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 0cbfe4ea4..23e733e94 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -723,6 +723,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; @@ -4251,6 +4252,12 @@ fhandler_console::fixup_after_fork_exec (bool execin= g) set_unit (); setup_io_mutex (); wpbuf.init (); + if (cygheap->ctty =3D=3D this && !get_handle () && !get_output_handle ()) + { + close_with_arch (); + cygheap->ctty =3D NULL; + return; + } =20 if (!execing) return;