- If the command executed is 'cmd.exe /c [...]', runpath in spawn.cc
will be NULL. In this case, is_console_app(runpath) check causes
access violation. This case also the command executed is obviously
console app., therefore, treat it as console app to fix this issue.
Addresses: https://github.com/msys2/msys2-runtime/issues/108
This simple testcase:
locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);
locale_t st2 = newlocale(LC_CTYPE_MASK, "en_US.UTF-8", st);
is sufficient to reproduce a crash in _newlocale_r. After the first call
to newlocale, `st' points to __C_locale, which is const. When using `st'
as locale base in the second call, _newlocale_r tries to set pointers
inside base to NULL. This is bad if base is __C_locale, obviously.
Add a test to avoid trying to overwrite pointer values inside base if
base is __C_locale.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Currently it is possible for symlink_info::check to return -1 in case
we're searching for foo and find foo.lnk that is not a Cygwin symlink.
This contradicts the new meaning attached to a negative return value
in commit 19d59ce75d. Fix this by setting "res" to 0 at the beginning
of the main loop and not seting it to -1 later.
Also fix the commentary preceding the function definition to reflect
the current behavior.
Addresses: https://cygwin.com/pipermail/cygwin/2022-August/252030.html
- 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.
- 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.
- 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.
- OpenClipboard() just after CloseClipboard() sometimes fails. Due
to this, /dev/clipboard sometimes fails to set CF_UNICODETEXT
data. This patch add a workaround for this issue.
- poll() has a bug that it returns event which is not inquired if
events are inquired in multiple pollfd entries on the same fd at
the same time. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251732.html
- 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.
The current definition of mknod in syscalls.cc has a third argument of
type __dev16_t instead of dev_t. Fix this on 64-bit Cygwin by making
the existing mknod 32-bit only and then exporting mknod as an alias
for mknod32. (No fix is needed on 32-bit because mknod is redirected
to mknod32 via NEW_FUNCTIONS in Makefile.am.)
Addresses: https://cygwin.com/pipermail/cygwin-developers/2022-May/012589.html
killpg(pgid, 0) (or kill_pgrp(pgid, si_signo=0), in signal.cc)
fails (returns -1) even when there is a process in the process
group pgid, if the process is in the middle of spawnve(), see
https://cygwin.com/pipermail/cygwin/2022-May/251479.html
When exec'ing a process the assumption is that the exec'ed process creates its
own symlink (in pinfo::thisproc() in pinfo.cc). If the exec'ing process
calls NtClose on it's own winpid symlink, but the exec'ed process didn't
progress enough into initialization, there's a slim chance that neither
the exec'ing process, nor the exec'ed process has a winpid symlink
attached.
Always create the winpid symlink in spawn.cc, even for exec'ed Cygwin
processes. Make sure to dup the handle into the new process, and stop
creating the winpid symlink in exec'ed processes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- Previously, the command "cmd /c script -c cmd" in console of Win7
crashes. This seems to be due to a bug (?) of AttachConsole().
This patch adds workaround for this issue.
Currently, pty reattaches to the console of the process which is
predetermined by ConsoleProcessList() after temporarily attaching
to another console. After that, the console output handle opened
with the name "CONOUT$" may not be accessible in Win7 or Vista.
This seems to happen when the attached process does not have the
same handle even if the console attached is the same. With this
patch, cygwin-console-helper which is started when pty master is
opened in console, is utilized to be a target process to which
pty reattaches if the OS is Win7 or Vista.
- Previously, script command sometimes crashes by Ctrl-C in Win 7
if it is running in console, and non-cygwin app is foreground.
This patch fixes the issue.
- 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.
- Previously, invisible console was created in fixup_after_exec().
However, actually this should be done in fixup_after_fork(). this
patch fixes the issue.
- When temporarily attaching a console, the timing of acquiring
attach_mutex was not appropriate. This sometimes caused master
forwarding thread to crash on Ctrl-C in Windows 7. This patch
fixes the issue.
Even after fork, we might need the parent sigmask without having
access to the real _main_tls. There's a short time at process startup,
when _main_tls points to the system-allocated stack, but wait_sig is
already running. If we can't lock _main_tls, because find_tls can't
find it yet, we now access the parent's sigmask via child_info.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
A recent patch fixed gmondump to stop printing "0x0x" as an address
prefix. It turns out the Cygwin User's Guide and the gmondump and
ssp man pages (all from utils.xml) have examples of the same error.
- In the latest GDB (11.2-1), Ctrl-C behaviour is broken a bit for
non-cygwin inferior. For example, Ctrl-C on GDB prompt is not sent
to GDB but to the inferior. This patch fixes the issue.
- The internal handles in HPCON should not be inheritable, however,
the current code duplicates them as inheritable when handing over
ownership of the pseudo console. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-April/251222.html
- Currently, close_pseudoconsole() is called unconditionally from
fhandler_termios::process_sigs() on Ctrl-C. This causes deadlock
if Ctrl-C is pressed while setup_pseudoconsole() is called. With
this patch, close_pseudoconsole() is called only if the master
process is the owner of the nat-pipe to avoid the deadlock.
- As mentioned in commit message of the commit b531d6b0, if multiple
writers including non-cygwin app exist, the non-cygwin app cannot
detect pipe closure on the read side when the pipe is created by
system account or the the pipe creator is running as service.
This is because query_hdl which is held in write side also is a
read end of the pipe, so the pipe is still alive for the non-cygwin
app even after the reader is closed.
To avoid this problem, this patch lets all processes in the same
process group close query_hdl using newly introduced internal signal
__SIGNONCYGCHLD when non-cygwin app is started.
Addresses: https://cygwin.com/pipermail/cygwin/2022-March/251097.html
- 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.
- dwControlKeyState also may be null'ed on WriteConsoleInputW().
Therefore ignore it in event comparison as well as wVirtualKeyCode
and wVirtualScanCode.
- 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.