msys2-runtime: patch to fix ctrl-c handling
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
From 54c3ecbf787d9d9d5646842802c3f1ea7855834f Mon Sep 17 00:00:00 2001
|
||||
From: Jeremy Drake <github@jdrake.com>
|
||||
Date: Mon, 21 Jun 2021 12:27:02 -0700
|
||||
Subject: [PATCH 42/N] Fix 64 vs 32-bit type confusion in swprintf.
|
||||
|
||||
kill_via_console_helper: use %u instead of %ld for DWORD.
|
||||
It appears that cygwin's swprintf is acting like LP64 instead of Windows
|
||||
LLP64, and expecting a 64-bit long. DWORDs are 32-bit unsigned.
|
||||
|
||||
Add check to avoid closing the handle from the input paramter. It may
|
||||
well be that the caller still intends to use it.
|
||||
|
||||
Minor fixes for Ctrl-C handling code.
|
||||
|
||||
From my post-merge review at https://github.com/msys2/msys2-runtime/pull/31#pullrequestreview-688771861
|
||||
---
|
||||
winsup/cygwin/include/cygwin/exit_process.h | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/winsup/cygwin/include/cygwin/exit_process.h b/winsup/cygwin/include/cygwin/exit_process.h
|
||||
index 19b8e60..5f926c9 100644
|
||||
--- a/winsup/cygwin/include/cygwin/exit_process.h
|
||||
+++ b/winsup/cygwin/include/cygwin/exit_process.h
|
||||
@@ -75,13 +75,14 @@ kill_via_console_helper (HANDLE process, wchar_t *function_name, int exit_code,
|
||||
|
||||
STARTUPINFOW si = {};
|
||||
PROCESS_INFORMATION pi;
|
||||
- size_t len = wcslen (wbuf) + wcslen (function_name) + 3 /* exit code */
|
||||
- + 1 /* space */ + 10 /* process ID, i.e. DWORD */ + 1 /* NUL */;
|
||||
+ size_t len = wcslen (wbuf) + 1 /* space */ + wcslen (function_name)
|
||||
+ + 1 /* space */ + 3 /* exit code */ + 1 /* space */
|
||||
+ + 10 /* process ID, i.e. DWORD */ + 1 /* NUL */;
|
||||
WCHAR cmd[len + 1];
|
||||
WCHAR title[] = L"cygwin-console-helper";
|
||||
DWORD process_exit;
|
||||
|
||||
- swprintf (cmd, len + 1, L"%S %S %d %ld", wbuf, function_name, exit_code,
|
||||
+ swprintf (cmd, len + 1, L"%S %S %d %u", wbuf, function_name, exit_code,
|
||||
pid);
|
||||
|
||||
si.cb = sizeof (si);
|
||||
@@ -194,10 +195,10 @@ exit_process_tree (HANDLE main_process, int exit_code)
|
||||
PROCESSENTRY32 entry;
|
||||
DWORD pids[16384];
|
||||
int max_len = sizeof (pids) / sizeof (*pids), i, len, ret = 0;
|
||||
- pid_t pid = GetProcessId (main_process);
|
||||
+ DWORD pid = GetProcessId (main_process);
|
||||
int signo = exit_code & 0x7f;
|
||||
|
||||
- pids[0] = (DWORD)pid;
|
||||
+ pids[0] = pid;
|
||||
len = 1;
|
||||
|
||||
/*
|
||||
@@ -249,6 +250,8 @@ exit_process_tree (HANDLE main_process, int exit_code)
|
||||
break;
|
||||
}
|
||||
|
||||
+ CloseHandle (snapshot);
|
||||
+
|
||||
for (i = len - 1; i >= 0; i--)
|
||||
{
|
||||
HANDLE process;
|
||||
@@ -262,7 +265,9 @@ exit_process_tree (HANDLE main_process, int exit_code)
|
||||
| PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
|
||||
FALSE, pids[i]);
|
||||
if (!process)
|
||||
- process = OpenProcess (PROCESS_TERMINATE, FALSE, pids[i]);
|
||||
+ process = OpenProcess (
|
||||
+ PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE,
|
||||
+ FALSE, pids[i]);
|
||||
}
|
||||
DWORD code;
|
||||
|
||||
@@ -272,7 +277,7 @@ exit_process_tree (HANDLE main_process, int exit_code)
|
||||
if (!exit_process (process, exit_code))
|
||||
ret = -1;
|
||||
}
|
||||
- if (process)
|
||||
+ if (process && process != main_process)
|
||||
CloseHandle (process);
|
||||
}
|
||||
|
||||
--
|
||||
2.32.0.windows.1
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
pkgbase=msys2-runtime
|
||||
pkgname=('msys2-runtime' 'msys2-runtime-devel')
|
||||
pkgver=3.2.0
|
||||
pkgrel=10
|
||||
pkgrel=11
|
||||
pkgdesc="Cygwin POSIX emulation engine"
|
||||
arch=('i686' 'x86_64')
|
||||
url="https://www.cygwin.com/"
|
||||
@@ -63,7 +63,8 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$
|
||||
0038-Cygwin-Add-missing-IsWow64Process2-declaration.patch
|
||||
0039-Add-a-helper-to-obtain-a-function-s-address-in-kerne.patch
|
||||
0040-Emulate-GenerateConsoleCtrlEvent-upon-Ctrl-C.patch
|
||||
0041-kill-kill-Win32-processes-more-gently.patch)
|
||||
0041-kill-kill-Win32-processes-more-gently.patch
|
||||
0042-Fix-64-vs-32-bit-type-confusion-in-swprintf.patch)
|
||||
sha256sums=('SKIP'
|
||||
'605f3f31dcca983fad2659f2d8f3531217e3f133757b40b0977e6a17c406c147'
|
||||
'5d120d24ce55ef08bf459781610e32c4a8e5e0eac73971a60e80590c6432d940'
|
||||
@@ -105,7 +106,8 @@ sha256sums=('SKIP'
|
||||
'82385daeed795666cf9e2e26a97e13417b714eba1011765285866f5467a4f0cf'
|
||||
'8475880df4ae8f109ed006c81177d50da5c5067bb63cb2dd7c2718993dd6b74d'
|
||||
'460adc6de940e25332efec7a6615bb95088ae0652870a1c0b4f37c72671444fe'
|
||||
'cc0bfded281675af09ce94d847e814f77fd5cbcd86b09b7436a0e91b7697b8f4')
|
||||
'cc0bfded281675af09ce94d847e814f77fd5cbcd86b09b7436a0e91b7697b8f4'
|
||||
'04ee4b9ca58bfa8a3c0370d1cecadf50c9c02daf6a4e5ccd4610336155538b71')
|
||||
|
||||
# Helper macros to help make tasks easier #
|
||||
apply_patch_with_msg() {
|
||||
@@ -183,7 +185,8 @@ prepare() {
|
||||
0038-Cygwin-Add-missing-IsWow64Process2-declaration.patch \
|
||||
0039-Add-a-helper-to-obtain-a-function-s-address-in-kerne.patch \
|
||||
0040-Emulate-GenerateConsoleCtrlEvent-upon-Ctrl-C.patch \
|
||||
0041-kill-kill-Win32-processes-more-gently.patch
|
||||
0041-kill-kill-Win32-processes-more-gently.patch \
|
||||
0042-Fix-64-vs-32-bit-type-confusion-in-swprintf.patch
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
Reference in New Issue
Block a user