From f3ba4db2e2b2839ae368c413794ac15da407b9a4 Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Fri, 16 Feb 2024 03:35:07 +0900 Subject: Cygwin: console: Fix a bug that 64th console cannot be handled. Fixes: 930e553da8e9 ("Cygwin: console: Unify EnumWindows() callback functions."); Signed-off-by: Takashi Yano --- winsup/cygwin/fhandler/console.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'winsup/cygwin/fhandler/console.cc') diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc index 66b4905..c16ca39 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -253,12 +253,10 @@ fhandler_console::enum_windows (HWND hw, LPARAM lp) } fhandler_console::console_unit::console_unit (int n0): - n (n0), bitmask (0) + n (n0), bitmask (0), shared_console_info (NULL) { EnumWindows (fhandler_console::enum_windows, (LPARAM) this); - if (n < 0) - n = (_minor_t) ffsl (~bitmask) - 1; - if (n < 0) + if (n0 == CONS_SCAN_UNUSED && (n = ffsl (~bitmask) - 1) < 0) api_fatal (sizeof (bitmask) == 8 ? "console device allocation failure - " "too many consoles in use, max consoles is 64" : @@ -674,7 +672,7 @@ fhandler_console::set_unit () ProtectHandleINH (cygheap->console_h); if (created) { - unit = console_unit (-1); + unit = console_unit (CONS_SCAN_UNUSED); cs->tty_min_state.setntty (DEV_CONS_MAJOR, unit); } else -- cgit v1.1