- The commit "Cygwin: console: Fix issues of apps which open pty."
did not fix the second problem correctly. That commit looked to
fix the issue, but the actual problem was that ctrl_c_handler()
should be reregistered *AFTER* FreeConsole()/AttachConsole().
This patch correct that.
- The commit "Cygwin: console: Restore CTRL_BREAK_EVENT handling."
was accidentally mixed with experimental code in exceptions.cc.
Due to this, non-cygwin app receives CTRL_C_EVENT twice in the
following scenario.
1) Run 'sleep 10 | <non-cygwin app>'
2) Hit Ctrl-C.
3) The non-cygwin app receives CTRL_C_EVENT twice.
This patch reverts the code with the problem.
- 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.
- The commit "Cygwin: console: Redesign handling of special keys."
removes special treatment for pty in with pseudo console activated,
however, it is necessary on second thought. This is because sending
CTRL_C_EVENT to non-cygwin apps will be done in pseudo console,
therefore, sending it in fhandler_pty_master::write() duplicates
that event for non-cygwin apps.
- 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.
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
0x00007f00. With this patch, the exit code will be 0x00000002,
which means process exited by SIGINT.
- 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.
- 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.
- 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.
Bash has a very convenient feature that is called process substitution
(e.g. `diff -u <(seq 0 10) <(seq 1 11)`). To make this work, Bash
requires the `/dev/fd` symlink to exist, and Cygwin therefore creates
this symlink (together with the `stdin`, `stdout` and `stderr` ones)
upon start-up.
This strategy is incompatible with the idea of providing a subset of
Cygwin in a `.zip` file (because there is no standard way to represent
symlinks in `.zip` files, and besides, older Windows versions would
potentially lack support for them anyway).
That type of `.zip` file is what Git for Windows wants to use, though,
bundling a minimal subset for third-party applications in MinGit (see
https://github.com/git-for-windows/git/wiki/MinGit for details).
Let's side-step this problem completely by creating those symlinks
implicitly, similar to the way `/dev/` is populated with special
devices.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
- 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.
- 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.
- 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).
- 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.
- The capability changes since Windows 11 have been reflected in
wincap.cc. The capability has_con_broken_tabs is added, which is
false since Windows 11.
- When non-cygwin app is started in console, console mode is set to
tty::native. However, if stdin is redirected, current code does not
set the input mode of the console. In this case, if the app opens
"CONIN$", the console mode will not be appropriate for non-cygwin
app. This patch fixes the issue.
Addresses:
https://github.com/GitCredentialManager/git-credential-manager/issues/576
- 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.
- In tty_min::setpgid(), a pointer to fhandler instance is casted to
fhandler_pty_slave and accessed even if terminal is not a pty slave.
This patch fixes the issue.
- Currently, pty discards input only in from_master pipe on signal.
Due to this, if pty is started without pseudo console support and
start a non-cygwin process from cmd.exe, type adhead input is not
discarded on signals such as Ctrl-C. This patch fixes the issue.
- With this patch, the code to wait for completion of forwarding of
output from non-cygwin app is revised so that it can more reliably
detect the completion.
- If the slave process writes a lot of text output, doecho() can
cause deadlock. This is because output_mutex is held in slave::
write() and if WriteFile() is blocked due to pipe full, doecho()
tries to acquire output_mutex and gets into deadlock. With this
patch, the deadlock is prevented on the sacrifice of atomicity
of doecho().
- Previously, non-cygwin app running in pty started without pseudo
console support was suspended by Ctrl-Z rather than sending EOF.
Even worse, suspended app could not be resumed by fg command. With
this patch, Ctrl-Z (EOF for non-cygwin apps) is passed to non-cygwin
app instead of suspending that app. This patch also handles Ctrl-\
(QUIT) and Ctrl-D (EOF) as well.
- 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.
- 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.
On second thought, we don't actually need this script.
Express the entire action as sufficiently simple Makefile rule.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- formatting
- use array pointer as argument rather than variable arguments
- syntactical fixes
- add comments
- drop unnecessary recomputation of all section VMAs.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
In Makefile.am, add the value of $(V) to the dllfixdbg call.
In dllfixdbg, if V=1, print what the script is doing.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Change dllfixdbg to keep the input DLL intact and just generate
a new DLL matching the debug file. Fix Makefile rule accordingly.
The result is, cygwin0.dll is the original DLL created with full
debug sections and stays that way throughout the build process.
Only new-cygwin1.dll will become the stripped DLL matching with
the file containing the debug sections cygwin1.dbg. This is ok,
because commit ba02fef995 ("Cygwin: Makefile.am: fix DLL build rule")
made new-cygwin1.dll the DLL to be installed.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- If an UNC path is mounted to a drive using SMB3.11, accessing to
the drive fails with error "Too many levels of symbolic links."
This patch fixes the issue.
A single Makefile rule creates three files in three steps, the second
and third one never showing up in dependencies. The next step creating
the link lib only depends on the first of these files. Even if the
second or third step in the DLL build rule fails, the next make
invocation never picks up on this and just goes ahead creating the
link lib.
Fix this by splitting the DLL build rule into three rules, with
every step on the way depending on the previous rule. Also fix up
the names, TEST_DLL_NAME just doesn't cut it.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This reverts commit 0390cc8572.
There's no indication what exact situation this patch was supposed to
solve, and local testing doesn't show any such problems. However, this
patch itself introduced a new problem, as outlined by
https://cygwin.com/pipermail/cygwin/2022-January/250629.html
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Commit a2bfe7cae6 introduced a change ignoring default ACEs on files
to come up with a valid POSIX ACL, reflecting the Windows ACEs actually
making sense on files.
However, if CREATOR OWNER or CREATOR GROUP ACEs - both only making sense
as default ACEs - are found in the ACL, a value indicating the presence
of default ACEs gets set, even on files. This in turn breaks a
subsequent integrity check and get_posix_access returns EINVAL.
The code path handling default ACEs on directories sets this indicator
anyway, so don't set it just because one of the above SIDs are found.
Fixes: a2bfe7cae6 ("Cygwin: ACLs: ignore *_INHERIT flags in file ACLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Unless make is invoked with V=1, have xmlto pass the parameter
'man.output.quietly=1' to xsltproc to suppress "Note: Writing foo.N"
output from the manpages stylesheet.
Unless make is invoked with V=1, have xmlto pass the parameter
'chunk.quietly=1' to xsltproc to suppress "Writing foo.html for
sect1(foo)" output from the chunker.xsl stylesheet.
Unless make is invoked with V=1, have xmlto pass '-q' to dblatex when
building PDFs, to supress repeated "default template used in
programlisting or screen" warnings from dblatex's verbatim.xsl
stylesheet.