diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc index c16ca3962..67ea95466 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -1926,9 +1926,11 @@ fhandler_console::close () || get_device () == (dev_t) myself->ctty)) free_console (); - if (shared_console_info[unit]) - UnmapViewOfFile ((void *) shared_console_info[unit]); - shared_console_info[unit] = NULL; + if (shared_console_info[unit] && myself->ctty != tc ()->ntty) + { + UnmapViewOfFile ((void *) shared_console_info[unit]); + shared_console_info[unit] = NULL; + } return 0; } diff --git a/winsup/cygwin/release/3.5.2 b/winsup/cygwin/release/3.5.2 new file mode 100644 index 000000000..7d8df9489 --- /dev/null +++ b/winsup/cygwin/release/3.5.2 @@ -0,0 +1,7 @@ +Fixes: +------ + +- Fix the problem that console setup accesses shared memory which + is already unmapped due to race condition. To avoid this issue, + shared console memory will be kept mapped if it belongs to CTTY. + Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255561.html