Since dcf0bf1f, one could no longer kill a GUI application launched from unix shell (with start.exe /exec) with ctrl-c.
(depends on https://gitlab.winehq.org/wine/wine/-/merge_requests/3310 to be fully functional).
Signed-off-by: Eric Pouech epouech@codeweavers.com
From: Eric Pouech epouech@codeweavers.com
Since dcf0bf1f, one could no longer kill a GUI application launched from unix shell (with start.exe /exec) with ctrl-c.
(depends on https://gitlab.winehq.org/wine/wine/-/merge_requests/3310 to be fully functional).
Signed-off-by: Eric Pouech epouech@codeweavers.com --- programs/start/start.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/programs/start/start.c b/programs/start/start.c index 59fd72e07a4..aebcea26eb1 100644 --- a/programs/start/start.c +++ b/programs/start/start.c @@ -27,6 +27,7 @@ #include <shellapi.h>
#include <wine/debug.h> +#include "winternl.h"
#include "resources.h"
@@ -395,12 +396,38 @@ static BOOL search_path(const WCHAR *firstParam, WCHAR **full_path) return FALSE; }
+static WORD get_pe_image_subsystem(const WCHAR *filename) +{ + HANDLE file, map = 0; + void *image = NULL; + const IMAGE_NT_HEADERS *ntheader; + WORD subsystem = IMAGE_SUBSYSTEM_UNKNOWN; + + if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE && + ((map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) && + ((image = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0)) != NULL) && + ((ntheader = RtlImageNtHeader(image)) != NULL)) + { + if (ntheader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) + subsystem = ((IMAGE_NT_HEADERS64*)ntheader)->OptionalHeader.Subsystem; + else if (ntheader->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) + subsystem = ((IMAGE_NT_HEADERS32*)ntheader)->OptionalHeader.Subsystem; + } + if (image) UnmapViewOfFile(image); + if (map) CloseHandle(map); + if (file != INVALID_HANDLE_VALUE) CloseHandle(file); + + return subsystem; +} + static struct { SHELLEXECUTEINFOW sei; WCHAR *title; DWORD creation_flags; USHORT machine; + BOOL ignore_ctrlc; } opts;
static void parse_command_line( int argc, WCHAR *argv[] ) @@ -408,6 +435,7 @@ static void parse_command_line( int argc, WCHAR *argv[] ) int i; const WCHAR *file = NULL; BOOL unix_mode = FALSE; + BOOL exec_mode = FALSE; BOOL progid_open = FALSE;
opts.sei.cbSize = sizeof(opts.sei); @@ -416,6 +444,7 @@ static void parse_command_line( int argc, WCHAR *argv[] ) /* Dunno what these mean, but it looks like winMe's start uses them */ opts.sei.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI; opts.creation_flags = CREATE_NEW_CONSOLE; + opts.ignore_ctrlc = FALSE;
/* Canonical Microsoft commandline flag processing: * flags start with / and are case insensitive. @@ -465,7 +494,10 @@ static void parse_command_line( int argc, WCHAR *argv[] ) else if (is_option(argv[i], L"/shared")) opts.creation_flags |= CREATE_SHARED_WOW_VDM; else if (is_option(argv[i], L"/w") || is_option(argv[i], L"/wait")) + { + opts.ignore_ctrlc = TRUE; opts.sei.fMask |= SEE_MASK_NOCLOSEPROCESS; + } else if (is_option(argv[i], L"/?")) usage(); else if (is_option_with_arg(argv, &i, L"/node")) @@ -490,6 +522,7 @@ static void parse_command_line( int argc, WCHAR *argv[] ) else if (is_option(argv[i], L"/exec")) { opts.creation_flags = 0; opts.sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE | SEE_MASK_FLAG_NO_UI; + exec_mode = TRUE; i++; break; } @@ -545,6 +578,8 @@ static void parse_command_line( int argc, WCHAR *argv[] ) if (search_path(file, &fullpath)) opts.sei.lpFile = fullpath; else opts.sei.lpFile = file; } + if (exec_mode && get_pe_image_subsystem(opts.sei.lpFile) == IMAGE_SUBSYSTEM_WINDOWS_CUI) + opts.ignore_ctrlc = TRUE; }
@@ -641,7 +676,8 @@ done: HANDLE hJob; JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
- SetConsoleCtrlHandler(NULL, TRUE); + if (opts.ignore_ctrlc) + SetConsoleCtrlHandler(NULL, TRUE); hJob = CreateJobObjectA(NULL, NULL); /* Create a job where the child is associated... if the start.exe terminates * before the child, the job will be terminated, and the child will be terminated as well.
about pipeline failures: - mac build error is about missing gst/gst.h - failures in test linux32 are about missing ALSA device so not related to this patch