Conversation
Currently, when cygwin app is launched, the console input mode is
set to tty::cygwin, even if the stdin is not a console. However,
it is not necessary because the cygwin app does not use stdin.
This also applies to stdout and stderr.
With this patch, the console mode is set only when std{in,out,err}
is a console for the cygwin app for better coexistence with non-
cygwin apps.
This is a prerequisite for the experimental backport of Takashi Yano's
v15 console-mode patch to msys2-3.6.10. The release branch's later,
already-applied suspension-before-mode ordering is preserved.
(cherry picked from commit bbd3710)
Assisted-by: GPT-6
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Previously, if two non-cygwin apps are started and one of them exits first, the other one lost appropriate console mode, since the first one restored it to tty::cygwin. This patch counts the active console process whose pgid is pgid of the tty and if the result is zero (means the last non-cygwin foreground process), restore console mode. To avoid race issue between apps modifying console mode simultaneously, this patch also introduce a mutex named `cons_mode_mutex`. Known limitation: In the case of non-overlayed spawn, there still exists a small window in which another non-cygwin process may restore tty::cygwin mode even though new non-cygwin app is about to start. In addition: Avoid the cleanup/startup deadlock: cleanup can hold `cons_mode_mutex` while waiting for a console master that a new owner cannot start until acquiring that mutex. Startup must precede the mode-mutex wait without changing the handshake or mode serialization. Backport v17 to the msys2-3.6.10 release branch after prerequisite c892dfe, preserving all additions from https://inbox.sourceware.org/cygwin-patches/20260917054034.7668-1-takashi.yano@nifty.ne.jp/ Fixes: 48285aa ("Cygwin: console: Fix handling of Ctrl-S in Win7.") Co-authored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Assisted-by: GPT-6 Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
With the commit 733d5a9 ("Cygwin: console: Ensure the master thread runs only when it is supposed to"), the process which calls set_disable_master_thread() hangs if the con.owner already exited, because set_disable_master_thread() waits for cons_master_thread accepting the status change and reflecting the current status to master_thread_suspended. With this patch, set_disable_master_thread() is aborted if the owner process no longer exists to avoid this hang. Backport owner-v3 unchanged on top of v17 to the msys2-3.6.10 release branch, including the owner-liveness handling suggested in Johannes's review: https://inbox.sourceware.org/cygwin-patches/20260917054209.7682-1-takashi.yano@nifty.ne.jp/ Addresses: https://cygwin.com/pipermail/cygwin/2026-September/260037.html Fixes: 733d5a9 ("Cygwin: console: Ensure the master thread runs only when it is supposed to") Reported-by: Jay Libove Alzina <libove@felines.org> Co-authored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Assisted-by: GPT-6 Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…in apps Signal exits, SA_RESTART retries and noncanonical reads needing more input can bypass deferred Win32 input-mode reconciliation. Apply pending changes before console reads and readiness checks retry or return. Invoke reconciliation only after releasing input_mutex to preserve the cons_mode_mutex-before-input_mutex lock order. Assisted-by: GPT-6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…on.owner An owner query failure does not necessarily mean the process exited, and observing exit is not a worker acknowledgement. Allow an owner-exit escape only on observed exit or absence, with con.owner still matching the captured owner. Leave the acknowledgement untouched and preserve -1 as normal retirement. Log inconclusive query or wait failures once per newly observed failing owner and keep waiting. Assisted-by: GPT-6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This was referenced Sep 18, 2026
Merged
Collaborator
Author
|
Superseded by #368 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is expected to be the final version of these two patches (plus prerequisite), or at least quite close to their final form.
(This AI-generated PR description still needs to be edited by
@dscho)This new draft tests the current upstream proposals against #351. #364 stays at v15 plus fixup
dbc070a9.try-console-mode-v17is based onmsys2-3.6.10(da84778cbc92), with this stack in order:c892dfe93ec1f5a82d299efca8c0297ff7ade794, backport of upstreambbd3710fc83451426e3a58e5032437ca535fa444.2b85c1d1c1fd.ea9117799e5c(tested HEAD).The committed trees were independently verified against the submissions. V17 required only the existing release-context/preimage adaptations; every added line is preserved, and owner-exit v3 was applied verbatim. No separate local fixup or instrumentation was added.
The local DLL-only build of
new-msys-2.0.dllsucceeded with the MSYS toolchain and tested HEAD embedded. The loaded runtime's path and hash were verified.Testing used the same #351 reproducer binary as the baseline/v15/v16 comparisons, based on
4a0117dawith existing child-command failure checks. Workload settings remained 99 jobs, concurrency 10, and unchanged delays. Five consecutive uninstrumented runs passed (495 jobs total): all IDs 1-99 andEND OF MAINobserved in every run, normal exit status 0, no child-command failures, and no monitor errors.Upstream review is ongoing. Local validation did not include the full utility/install/MSYS2 CI matrix or a new compiler bootstrap. These results cover the #351 workload, not every console race or a general resolution of MSYS2-packages#6445.