Skip to content

Commit b160d8e

Browse files
authored
Merge pull request #231 from git-for-windows/msys2-runtime-bb4e8e05b4c68895887eba9c420e8a42e0e2801e
msys2-runtime: update to 3.6.1-2
2 parents 56a261b + 4855c88 commit b160d8e

File tree

4 files changed

+134
-6
lines changed

4 files changed

+134
-6
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
From 8ed79cf850b602a8fe6432027145f871f04d5690 Mon Sep 17 00:00:00 2001
2+
From: Takashi Yano <[email protected]>
3+
Date: Thu, 10 Apr 2025 16:18:17 +0900
4+
Subject: [PATCH 48/N] Cygwin: console: Fix the console states after the
5+
console is closed
6+
7+
Due to a bug introduced by the commit 3312f2d21f13, when the parent
8+
process exits before the child process exits, disable_master_thread
9+
is wrongly set to true, that disables special key handling such as
10+
Ctrl-C. With this patch, the disable_master_thread is set to true if
11+
any of the following conditions is met.
12+
- The parent process is not a cygwin process.
13+
- The master process already died.
14+
- The current process is the master process.
15+
Otherwise, disable_master_thread remains false to keep special key
16+
handling enabled.
17+
18+
Addresses: https://cygwin.com/pipermail/cygwin/2025-April/257909.html
19+
Fixed: 3312f2d21f13 ("Cygwin: console: Redesign mode set strategy on close().")
20+
Reported-by: Jeremy Drake <[email protected]>
21+
Signed-off-by: Takashi Yano <[email protected]>
22+
---
23+
winsup/cygwin/fhandler/console.cc | 24 ++++++++++++++++++++----
24+
winsup/cygwin/local_includes/fhandler.h | 2 +-
25+
2 files changed, 21 insertions(+), 5 deletions(-)
26+
27+
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
28+
index a38487f..f33e354 100644
29+
--- a/winsup/cygwin/fhandler/console.cc
30+
+++ b/winsup/cygwin/fhandler/console.cc
31+
@@ -932,7 +932,7 @@ fhandler_console::cleanup_for_non_cygwin_app (handle_set_t *p)
32+
/* Cleaning-up console mode for non-cygwin app. */
33+
/* conmode can be tty::restore when non-cygwin app is
34+
exec'ed from login shell. */
35+
- tty::cons_mode conmode = cons_mode_on_close ();
36+
+ tty::cons_mode conmode = cons_mode_on_close (p);
37+
set_output_mode (conmode, ti, p);
38+
set_input_mode (conmode, ti, p);
39+
set_disable_master_thread (con.owner == GetCurrentProcessId ());
40+
@@ -1991,8 +1991,9 @@ fhandler_console::close (int flag)
41+
42+
acquire_output_mutex (mutex_timeout);
43+
44+
- if (shared_console_info[unit] && myself->ppid == 1
45+
- && (dev_t) myself->ctty == get_device ())
46+
+ if (shared_console_info[unit] && con.curr_input_mode != tty::restore
47+
+ && (dev_t) myself->ctty == get_device ()
48+
+ && cons_mode_on_close (&handle_set) == tty::restore)
49+
{
50+
set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
51+
set_input_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
52+
@@ -4704,10 +4705,25 @@ fhandler_console::fstat (struct stat *st)
53+
}
54+
55+
tty::cons_mode
56+
-fhandler_console::cons_mode_on_close ()
57+
+fhandler_console::cons_mode_on_close (handle_set_t *p)
58+
{
59+
+ int unit = p->unit;
60+
if (myself->ppid != 1) /* Execed from normal cygwin process. */
61+
return tty::cygwin;
62+
63+
+ if (!process_alive (con.owner)) /* The Master process already died. */
64+
+ return tty::restore;
65+
+ if (con.owner == GetCurrentProcessId ()) /* Master process */
66+
+ return tty::restore;
67+
+
68+
+ PROCESS_BASIC_INFORMATION pbi;
69+
+ NTSTATUS status =
70+
+ NtQueryInformationProcess (GetCurrentProcess (), ProcessBasicInformation,
71+
+ &pbi, sizeof (pbi), NULL);
72+
+ if (NT_SUCCESS (status)
73+
+ && !process_alive ((DWORD) pbi.InheritedFromUniqueProcessId))
74+
+ /* Execed from normal cygwin process and the parent has been exited. */
75+
+ return tty::cygwin;
76+
+
77+
return tty::restore; /* otherwise, restore */
78+
}
79+
diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h
80+
index 8c71d84..4c013dd 100644
81+
--- a/winsup/cygwin/local_includes/fhandler.h
82+
+++ b/winsup/cygwin/local_includes/fhandler.h
83+
@@ -2368,7 +2368,7 @@ private:
84+
85+
void setup_pcon_hand_over ();
86+
static void pcon_hand_over_proc ();
87+
- static tty::cons_mode cons_mode_on_close ();
88+
+ static tty::cons_mode cons_mode_on_close (handle_set_t *);
89+
90+
friend tty_min * tty_list::get_cttyp ();
91+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 0cfedd4f820f1b32ea0a7d8afd2795bd4910ae16 Mon Sep 17 00:00:00 2001
2+
From: Jeremy Drake <[email protected]>
3+
Date: Thu, 10 Apr 2025 10:18:01 -0700
4+
Subject: [PATCH 49/N] fixup! Instead of creating Cygwin symlinks, use deep
5+
copy by default
6+
7+
Adjust the infinite recursion check to make sure the source ends with a
8+
dir sep, so it doesn't think abcd is a subdirectory of a.
9+
10+
Fixes #277
11+
12+
Signed-off-by: Jeremy Drake <[email protected]>
13+
---
14+
winsup/cygwin/path.cc | 4 +++-
15+
1 file changed, 3 insertions(+), 1 deletion(-)
16+
17+
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
18+
index 26ca1cf..6e35c5d 100644
19+
--- a/winsup/cygwin/path.cc
20+
+++ b/winsup/cygwin/path.cc
21+
@@ -1855,7 +1855,9 @@ recursiveCopy (PUNICODE_STRING src, PUNICODE_STRING dst, USHORT origsrclen,
22+
/* Recurse into the child directory */
23+
/* avoids endless recursion */
24+
if (src->Length <= origsrclen ||
25+
- !wcsncmp (src->Buffer, dst->Buffer, origdstlen / sizeof (WCHAR)))
26+
+ (!wcsncmp (src->Buffer, dst->Buffer, origdstlen / sizeof (WCHAR)) &&
27+
+ (!src->Buffer[origdstlen / sizeof (WCHAR)] ||
28+
+ iswdirsep(src->Buffer[origdstlen / sizeof (WCHAR)]))))
29+
{
30+
set_errno (ELOOP);
31+
goto done;

msys2-runtime/PKGBUILD

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pkgbase=msys2-runtime
55
pkgname=('msys2-runtime' 'msys2-runtime-devel')
66
pkgver=3.6.1
7-
pkgrel=1
7+
pkgrel=2
88
pkgdesc="Cygwin POSIX emulation engine"
99
arch=('x86_64')
1010
url="https://www.cygwin.com/"
@@ -73,9 +73,11 @@ source=('msys2-runtime'::git+https://github.com/cygwin/cygwin#tag=cygwin-${pkgve
7373
0044-Make-paths-WCS-MBS-conversion-explicit.patch
7474
0045-Use-MB_CUR_MAX-6-by-default.patch
7575
0046-Change-the-default-base-address-for-x86_64.patch
76-
0047-msys2-runtime-restore-fast-path-for-current-user-pri.patch)
76+
0047-msys2-runtime-restore-fast-path-for-current-user-pri.patch
77+
0048-Cygwin-console-Fix-the-console-states-after-the-cons.patch
78+
0049-fixup-Instead-of-creating-Cygwin-symlinks-use-deep-c.patch)
7779
sha256sums=('24c4782e0e48d59f4155885c790d37a8bb59c4ab318851b99c675ca83792f563'
78-
'a6d99dab3a1a91957d686d26d5157d601d89d271491744c5f6010bc3aff9d0c3'
80+
'2280305f1f4a8f851abd3e24823f05d853e124ff34c56754fca18dabf1ea49d6'
7981
'f0fb7e2f29859d57fd61edf2fb5453f975117aa6c53400f79e6d0eecf9dddba2'
8082
'3083f60db3649474270319856e8ecb39b15015ad49df4e1ab8c93a0ad3a71152'
8183
'27c196e05e46f26b86b2154b048aac0727b7303c464263e49016aabf63335dfd'
@@ -122,7 +124,9 @@ sha256sums=('24c4782e0e48d59f4155885c790d37a8bb59c4ab318851b99c675ca83792f563'
122124
'cf13908873f7b67575080f55dc2e162b2b63aabae0bba07382bef91b31c8a32c'
123125
'2db6a3c777144343dfa40f02bbae7a9bfda843407549da42f6be4f0a131a5ad6'
124126
'84a91ae1cf46d7e358754a33d85c7580578c3e4f12776e4fd70f43e8258bd209'
125-
'b13471f6459eb725ba85ee712e0c037b92d5128329b2dc599823e37bfa87812e')
127+
'b13471f6459eb725ba85ee712e0c037b92d5128329b2dc599823e37bfa87812e'
128+
'f2d679b59f68ddf025edb191d8888dcc783f85ea6ce63609fb9d562b5bcc9e7f'
129+
'2194f705bfa4fae545fecd0251bd03acacc76a6f18783a281b8eb60dec166d9d')
126130

127131
# Helper macros to help make tasks easier #
128132
apply_patch_with_msg() {
@@ -223,7 +227,9 @@ prepare() {
223227
0044-Make-paths-WCS-MBS-conversion-explicit.patch \
224228
0045-Use-MB_CUR_MAX-6-by-default.patch \
225229
0046-Change-the-default-base-address-for-x86_64.patch \
226-
0047-msys2-runtime-restore-fast-path-for-current-user-pri.patch
230+
0047-msys2-runtime-restore-fast-path-for-current-user-pri.patch \
231+
0048-Cygwin-console-Fix-the-console-states-after-the-cons.patch \
232+
0049-fixup-Instead-of-creating-Cygwin-symlinks-use-deep-c.patch
227233
}
228234

229235
build() {

msys2-runtime/msys2-runtime.commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
754b26f8483bf6b333fd01d58dad4341e4b6d8a8
1+
bb4e8e05b4c68895887eba9c420e8a42e0e2801e

0 commit comments

Comments
 (0)