This old kludge code assigns fhandler_console for /dev/tty even if the CTTY is not a console when stat() has been called. Due to this, the problem reported in https://cygwin.com/pipermail/cygwin/2023-June/253888.html occurs after the commit 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.").
This patch fixes the issue by dropping the old kludge code. Reported-by: Bruce Jerrick <bmj...@gmail.com> Signed-off-by: Takashi Yano <takashi.y...@nifty.ne.jp> --- winsup/cygwin/dtable.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 18e0f3097..9427e238e 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -598,12 +598,7 @@ fh_alloc (path_conv& pc) fh = cnew (fhandler_mqueue); break; case FH_TTY: - if (!pc.isopen ()) - { - fhraw = cnew_no_ctor (fhandler_console, -1); - debug_printf ("not called from open for /dev/tty"); - } - else if (!CTTY_IS_VALID (myself->ctty) && last_tty_dev + if (!CTTY_IS_VALID (myself->ctty) && last_tty_dev && !myself->set_ctty (fh_last_tty_dev, 0)) debug_printf ("no /dev/tty assigned"); else if (CTTY_IS_VALID (myself->ctty)) -- 2.39.0