aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler_console.cc
AgeCommit message (Collapse)AuthorFilesLines
2022-08-05Cygwin: Reorganize cygwin source dirCorinna Vinschen1-4333/+0
Create subdirs and move files accordingly: - DevDocs: doc files - fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc - local_includes: local include files - scripts: scripts called during build - sec: security sources Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04Cygwin: drop all usages of WINAPICorinna Vinschen1-5/+5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-02Cygwin: console: Modify ConEmu cygwin connector hook.Takashi Yano1-11/+6
- Previously, LoadLibraryA() is hooked for ConEmu cygwin connector. With this patch, GetProcAddress() for "RequestTermConnector" is hooked instead which is more essential for ConEmu cygwin connector.
2022-07-29Cygwin: console: Avoid accessing NULL pointer via cygheap->ctty.Takashi Yano1-8/+14
- Recent commit "Cygwin: console: Add missing input_mutex guard." has a problem that causes NULL pointer access if cygheap->ctty is NULL. This patch fixes the issue.
2022-07-28Cygwin: console: Add workaround for ConEmu cygwin connector.Takashi Yano1-0/+25
- ConEmu cygwin connector conflicts with cons_master_thread since it does not use read() to read console input. With this patch, cons_master_thread is disabled in ConEmu cygwin connector.
2022-07-28Cygwin: console: Add missing input_mutex guard.Takashi Yano1-6/+17
- Setting con.disable_master_thread flag should be guarded by input_mutex, however, it was not. This patch fixes that.
2022-07-09Cygwin: console: Fix an issue which causes when realloc() fails.Takashi Yano1-5/+13
2022-07-05Cygwin: console: Fix issue of pasting very long text input again.Takashi Yano1-22/+65
- The recent commit "Cygwin: console: Allow pasting very long text input." did not fix the issue enough. This patch adds fixes for that.
2022-07-03Cygwin: console: Fix new bugs in cons_master_thread().Takashi Yano1-8/+9
- The previous commit for console introduced new bugs in error handling in cons_master_thread(). This patch fixes that.
2022-07-02Cygwin: console: Allow pasting very long text input.Takashi Yano1-27/+94
- Currently, if the text longer than 1024 byte is pasted in console, some of the text is discarded. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251764.html
2022-06-19Cygwin: console: Handle setting very long window title correctly.Takashi Yano1-24/+66
- Previously, the console code could not handle escape sequence setting window title longer than 256 byte correctly. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251662.html
2022-06-14Cygwin: console: Retain ENABLE_VIRTUAL_TERMIANL_PROCESSING flag.Takashi Yano1-0/+4
- Currently, ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is disabled unconditionally when exiting from cygwin. This causes ANSI escape sequence disabled in Windows Terminal where it is enables by default. This patch retains that flag if it is originally enabled.
2022-06-06Cygwin: remove most occurrences of __stdcall and __cdeclKen Brown1-2/+2
These have no effect on x86_64. Retain a few occurrences of __cdecl in files imported from other sources. Also retain all occurrences of WINAPI, even though the latter is simply a macro that expands to __stdcall. Most of these occurrences are associated with Windows API functions, and removing them might make the code confusing instead of simpler.
2022-05-29Cygwin: remove regparm.hKen Brown1-7/+7
This file defines the macros __reg1, __reg2, and __reg3, which are defined to be empty on 64-bit Cygwin. Remove all occurrences of these macros.
2022-05-09Cygwin: pty: Not to change code page of parent console.Takashi Yano1-1/+1
- The recent commit "Cygwin: pty: Fix timing of creating invisible console." breaks the feature added by commit 72770148, which prevents pty from changing code page of parent console. This patch restores that.
2022-03-19Cygwin: console: Do not use memcmp() to compare INPUT_RECORD.Takashi Yano1-3/+38
- Using memcmp() to compare structure such as INPUT_RECORD is not correct manner because padding may not be initialized. This patch stops to use memcmp() for comparison of INPUT_RECORD.
2022-03-19Cygwin: console: Ignore dwControlKeyState in event comparison.Takashi Yano1-3/+3
- dwControlKeyState also may be null'ed on WriteConsoleInputW(). Therefore ignore it in event comparison as well as wVirtualKeyCode and wVirtualScanCode.
2022-03-18Cygwin: console: Add attach_mutex guard that was not added.Takashi Yano1-0/+2
2022-03-18Cygwin: console: Fix typeahead key swapping which still occurs.Takashi Yano1-20/+38
- The commit "Cygwin: console: Improve the code to avoid typeahead key swapping." did not solve the problem enough. Two unexpected things happen. (1) wVirtualKeyCode and wVirtualScanCode of readback key event may be null'ed even if they are not zero on WriteConsoleInputW(). Therefore, memcmp() may report the event sequence is not equal. (2) WriteConsoleInputW() may not be atomic. The event sequence which is written by WriteConsoleInputW() may be inserted by key input in the middle of the sequence. Current code gives up to fix in this situation. This patch should fix that issue.
2022-03-02Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.Takashi Yano1-31/+107
- This patch revises the acquiring/releasing timing for attach_mutex to make the period in which it is being acquired shorter. Further, acquiring/releasing are added to where they are missing but needed.
2022-03-02Cygwin: console: Fix a bug from comparison between int and DWORD.Takashi Yano1-1/+1
2022-03-02Cygwin: console: Prevent special keys processing from drop.Takashi Yano1-9/+13
- There was a potential risk to drop special key processing when process_input_messsage() is called intermittently. This patch fixes the issue.
2022-03-02Cygwin: console: Stop to create struct instance which is not needed.Takashi Yano1-9/+9
- In fhandler_console::cons_master_thread(), a struct which has only a static function is used. In this case, struct instance is not necessary. So with this patch, the static function is invoked without creating instance.
2022-02-28Cygwin: console: Improve the code to avoid typeahead key swapping.Takashi Yano1-33/+42
- The commit "Cygwin: console: Prevent the order of typeahead input from swapped." did not fully resolve the issue. If keys are typed during input buffer fix, the order of key event may be swapped. This patch fixes the issue again.
2022-02-26Cygwin: console: Prevent the order of typeahead input from swapped.Takashi Yano1-2/+51
- If a lot of keys are typed very quickly in the app which does not read console, the order of input keys in console input buffer occasionally swapped. Although this extremely rarely happens, is obviously a bug of cons_master_thread. This patch fixes the issue.
2022-02-26Cygwin: console: Fix issues of apps which open pty.Takashi Yano1-10/+10
- After some recent changes for special keys handling break the apps which open pty (such as script command). If the app which opens pty is executed in console, the following issues occur. 1) If the script command was started from non-cygwin shell (such as cmd.exe), another cygwin app started in pty slave cannot receive Ctrl-C. 2) If non-cygwin app is executed in pty slave, the app which opened the pty (e.g. script command) crashes by Ctrl-C. This patch fixes these issues.
2022-02-24Cygwin: console: Restore CTRL_BREAK_EVENT handling.Takashi Yano1-8/+3
- The recent change by the commit "Cygwin: console: Redesign handling of special keys." breaks the handling of CTRL_BREAK_EVENT. The login shell in console exits on Ctrl-Break key. This patch fixes the issue.
2022-02-24Cygwin: pty, console: Add a workaround for GDB SIGINT handling.Takashi Yano1-0/+1
- The inferior of the GDB cannot be continued after SIGINT even though nopass option is set. This seems because cygwin GDB does not support hooking cygwin signal. Therefore, a workaround for GDB is added. With this patch, only CTRL_C_EVENT is sent to the GDB inferior by Ctrl-C and sending SIGINT is omitted. Note that "handle SIGINT (no)pass" command does not take effect even with or without this patch.
2022-02-24Cygwin: console: Redesign handling of special keys.Takashi Yano1-19/+30
- This patch rearranges the cooperation between cons_master_thread, line_edit, and ctrl_c_handler so that only one of them operates at the same time. Since these handle Ctrl-C individually, so the signal may be sent multiple times to the process. This patch fixes the issue.
2022-02-22Cygwin: pty, console: Fix handle leak which occurs on exec() error.Takashi Yano1-10/+7
- This patch fixes the handle leak which occurs when exec() fails with an error. The duplicated handles will be closed when the exec'ed process is terminated. However, if exec() fails, the code path does not reach to the code closing the duplicated handles. To implement this fix more appropriately, the setup, cleanup and closing pty codes which was previously located in spawn.cc are encapsulated into the fhandler_pty_slave class functions.
2022-02-20Cygwin: console: Call fix_tab_position() only if having broken tabs.Takashi Yano1-3/+5
- Calling fix_tab_position() is necessary in Windows 10 with xterm compatible mode enabled, because it has a problem that the tab positions will be broken when the window size is changed. Fortunately, this problem has been fixed in Windows 11. Therefore, with this patch, necessity of fix_tab_position() call is determined by referring to wincap.has_con_broken_tabs(), which is recently introduced.
2022-02-20Cygwin: console: Rearrange set_(in|out)put_mode() calls.Takashi Yano1-25/+68
- With this patch, all set_(in|out)put_mode() calls are rearranged as follows. 1) Setup for cygwin apps, started from non-cygwin app, is done in fhandler_console::post_open_setup(), which overrides fhandler_base::post_open_setup() called from dtable.cc. 2) Cleanup for cygwin app is done in fhandler_console::close(). 3) Setup for cygwin apps is also in fhandler_console::bg_check(), which overrides fhandler_termios::bg_check(). This is called on read(), write() and select() for console. It is necessary if cygwin and non-cygwin apps are started simultaneously in the same process group. 4) Setup for non-cygwin apps is done in spawn.cc via fhandler_console::setup_console_for_non_cygwin_app(). 5) Cleanup for non-cygwin app is done in spawn.cc vid fhandler_console::cleanup_console_for_non_cygwin_app(). 6) Setup for non-cygwin app started by GDB is done in fhandler_console::set_console_mode_to_native(). 7) No explicit cleanup for non-cygwin app started by GDB, because console mode is automatically reset to tty::cygwin on read()/ write() in GDB thanks to 3).
2022-02-20Cygwin: pty, console: Refactor the code processing special keys.Takashi Yano1-86/+49
- This patch commonize the code which processes special keys in pty and console to improve maintanancibility. As a result, some small bugs have been fixed.
2022-02-13Cygwin: console: Fix console mode for non-cygwin inferior of GDB.Takashi Yano1-0/+39
- Currently, there is no chance to change console mode for non-cygwin inferior of GDB. With this patch, the console mode is changed to tty::native in CreateProcess() and ContinueDebugEvent() hooked in fhandler_console.
2022-02-13Cygwin: pty, console: Fix Ctrl-C handling for non-cygwin apps.Takashi Yano1-0/+28
- Currently, if cat is started from cmd.exe which is started in cygwin console, Ctrl-C terminates not only cat but also cmd.exe. This also happens in pty in which pseudo console is disabled. This patch fixes the issue.
2022-02-11Cygwin: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.Mitchell Hentges1-3/+5
- Currently, ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE are cleared if cygwin is started in console. These flags will not be recovered even when exiting from cygwin. Also note that if ENABLE_EXTENDED_FLAGS is once unset, then the flag ENABLE_QUICK_EDIT_MODE it's associated with will no longer be preserved. Unfortunately, we're accidentally stepping on this in fhandler_console::set_input_mode(). This patch solves this by carrying forward these flags in the place where it had been ignoring them. Since the previous behaviour of leaving these flags unset would essentially maintain their existing state, adding the carry-over of the flags now should not alter console behaviour.
2022-02-05Cygwin: console: Remove unnecessary (redundant) code.Takashi Yano1-2/+0
2022-02-03Cygwin: console: Fix IL/DL escape sequence on the last line.Takashi Yano1-0/+12
- Currently, escape sequence IL/DL (CSI Ps L, CSI Ps M) does not work correctly at the last (bottom end) line. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-February/250736.html
2022-01-14Cygwin: pty: Stop closing and recreating attach_mutex.Takashi Yano1-17/+0
- Closing attach_mutex and recreating it causes the race issue between pty and console codes. With this patch, attach_mutex is created only once in a process which opens pty, and never closed in order to avoid this issue. Addresses: https://cygwin.com/pipermail/cygwin-developers/2021-December/012548.html
2022-01-14Cygwin: pty, console: Fix deadlock in GDB regarding mutex.Takashi Yano1-17/+60
- GDB inferior may be suspended while the inferior grabs mutex. This causes deadlock in terminal I/O. With this patch, timeout for waiting mutex is set to 0 for the debugger process when the process calls CreateProcess() with DEBUG_PROCESS flag to avoid deadlock. This may cause the race issue in GDB, however, there is no other way than that. Addresses: https://cygwin.com/pipermail/cygwin-developers/2021-December/012542.html
2021-12-02Cygwin: console: Fix OSC sequence handling.Takashi Yano1-7/+24
- Currently, some OSC escape sequences, such as 'OSC 110 BEL', are not handled correctly. This patch fixes the issue.
2021-11-18Cygwin: console: Fix interference issue regarding master thread.Takashi Yano1-0/+11
- This patch fixes the issue that ReadConsoleInputW() call in the master thread interferes with the input process of non-cygwin apps.
2021-11-16Cygwin: console: Handle Unicode surrogate pairs.Johannes Schindelin1-1/+16
When running Cygwin's Bash in the Windows Terminal (see https://docs.microsoft.com/en-us/windows/terminal/ for details), Cygwin is receiving keyboard input in the form of UTF-16 characters. UTF-16 has that awkward challenge that it cannot map the full Unicode range, and to make up for it, there are the ranges U+D800-U+DBFF and U+DC00-U+DFFF which are illegal except when they come in a pair encoding for Unicode characters beyond U+FFFF. Cygwin does not handle such surrogate pairs correctly at the moment, as can be seen e.g. when running Cygwin's Bash in the Windows Terminal and then inserting an emoji (e.g. via Windows + <dot>, which opens an emoji picker on recent Windows versions): Instead of showing an emoji, this shows the infamous question mark in a black triangle, i.e. the invalid Unicode character. Let's special-case surrogate pairs in this scenario. This fixes https://github.com/git-for-windows/git/issues/3281 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-11-02Cygwin: console: Fix a bug on input when signalled.Takashi Yano1-0/+4
- This patch fixes the bug that Ctrl-C sometimes does not work as expected in Windows Terminal. Addresses: https://cygwin.com/pipermail/cygwin/2021-November/249749.html
2021-10-29Cygwin: drop support for simple invisible console codeCorinna Vinschen1-32/+2
i. e., Vista/2008. AllocConsole appears to allow creating a console only on the currently visible desktop since Windows 7, which broke the simple code opening the console on an invisible desktop in an invisible window station. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-10-10Cygwin: pty: Fix handle leak regarding attach_mutex.Takashi Yano1-1/+1
- If the process having master pty opened is forked, attach_mutex fails to be closed when master is closed. This patch fixes the issue.
2021-09-18Cygwin: allow open_setup to failKen Brown1-2/+2
Convert fhandler_base::open_setup to a (virtual) method that returns a bool result. For the moment, it and its overrides always return true.
2021-07-06Cygwin: console: Fix garbled input for non-ASCII chars.Takashi Yano1-6/+9
- After the commit ff4440fc, non-ASCII input may sometimes be garbled. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2021-June/248775.html
2021-07-06Revert "Cygwin: console: Fix garbled input for non-ASCII chars."Corinna Vinschen1-2/+2
This reverts commit 1b242c12aa7f34d89d57023f3c33f5f88d89d476.
2021-07-06Cygwin: console: Fix garbled input for non-ASCII chars.Takashi Yano1-2/+2
- After the commit ff4440fc, non-ASCII input may sometimes be garbled. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2021-June/248775.html