diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-03-01 19:05:36 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-03-01 20:00:11 +0900 |
commit | c77a5689f7bd4520f6d87481fd08591747b5da0f (patch) | |
tree | fd7c70113259f13593fe04a97f59a5555385877e /winsup/cygwin/fhandler/console.cc | |
parent | ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042 (diff) | |
download | newlib-c77a5689f7bd4520f6d87481fd08591747b5da0f.zip newlib-c77a5689f7bd4520f6d87481fd08591747b5da0f.tar.gz newlib-c77a5689f7bd4520f6d87481fd08591747b5da0f.tar.bz2 |
Cygwin: console: Do not unmap shared console memory belonging to ctty.
In the condition that console setup for CTTY and close run at the
sametime, accessing shared console memory which is already unmapped
may occur. With this patch, to avoid this race issue, shared console
memory which belongs to contorolling terminal (CTTY) is kept mapped
as before.
Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255561.html
Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Kate Deplaix <kit-ty-kate@outlook.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup/cygwin/fhandler/console.cc')
-rw-r--r-- | winsup/cygwin/fhandler/console.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc index c16ca39..67ea954 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; } |