mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
wineconsole-Forward_Exitcode: Update patchset, avoid waiting when console is closed by user.
This commit is contained in:
parent
49d6414382
commit
800c42803f
@ -4820,11 +4820,14 @@ fi
|
||||
# Patchset wineconsole-Forward_Exitcode
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * programs/wineconsole/winecon_private.h, programs/wineconsole/wineconsole.c
|
||||
# | * programs/wineconsole/curses.c, programs/wineconsole/user.c, programs/wineconsole/winecon_private.h,
|
||||
# | programs/wineconsole/wineconsole.c
|
||||
# |
|
||||
if test "$enable_wineconsole_Forward_Exitcode" -eq 1; then
|
||||
patch_apply wineconsole-Forward_Exitcode/0001-wineconsole-Forward-child-process-exitcode.patch
|
||||
patch_apply wineconsole-Forward_Exitcode/0001-wineconsole-Consistently-return-nonzero-exitcode-on-.patch
|
||||
patch_apply wineconsole-Forward_Exitcode/0002-wineconsole-Forward-child-process-exitcode.patch
|
||||
(
|
||||
echo '+ { "Sebastian Lackner", "wineconsole: Consistently return nonzero exitcode on error.", 1 },';
|
||||
echo '+ { "Michael Müller", "wineconsole: Forward child process exitcode.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
@ -0,0 +1,117 @@
|
||||
From 4134e0b939a4194bc961231523e381fa83806b33 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Mon, 13 Jul 2015 20:51:29 +0200
|
||||
Subject: wineconsole: Consistently return nonzero exitcode on error.
|
||||
|
||||
---
|
||||
programs/wineconsole/curses.c | 2 +-
|
||||
programs/wineconsole/user.c | 2 +-
|
||||
programs/wineconsole/wineconsole.c | 28 +++++++++++++++-------------
|
||||
3 files changed, 17 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c
|
||||
index 2903b80..7413c8f 100644
|
||||
--- a/programs/wineconsole/curses.c
|
||||
+++ b/programs/wineconsole/curses.c
|
||||
@@ -1018,7 +1018,7 @@ static int WCCURSES_MainLoop(struct inner_data* data)
|
||||
|
||||
WCCURSES_Resize(data);
|
||||
|
||||
- if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 0;
|
||||
+ if (pipe( PRIVATE(data)->sync_pipe ) == -1) return 1;
|
||||
PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id );
|
||||
|
||||
while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0)
|
||||
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
|
||||
index 5c8c2c0..4725ebd 100644
|
||||
--- a/programs/wineconsole/user.c
|
||||
+++ b/programs/wineconsole/user.c
|
||||
@@ -1382,7 +1382,7 @@ static int WCUSER_MainLoop(struct inner_data* data)
|
||||
* so GetMessage would lead to delayed processing */
|
||||
while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
|
||||
{
|
||||
- if (msg.message == WM_QUIT) return 0;
|
||||
+ if (msg.message == WM_QUIT) return 1;
|
||||
WINE_TRACE("dispatching msg %04x\n", msg.message);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
|
||||
index bdd5629..4ea5f84 100644
|
||||
--- a/programs/wineconsole/wineconsole.c
|
||||
+++ b/programs/wineconsole/wineconsole.c
|
||||
@@ -747,16 +747,18 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
|
||||
}
|
||||
|
||||
done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info);
|
||||
+ if (done)
|
||||
+ {
|
||||
+ CloseHandle(info.hProcess);
|
||||
+ CloseHandle(info.hThread);
|
||||
+ }
|
||||
|
||||
/* we no longer need the handles passed to the child for the console */
|
||||
CloseHandle(startup.hStdInput);
|
||||
CloseHandle(startup.hStdOutput);
|
||||
CloseHandle(startup.hStdError);
|
||||
|
||||
- CloseHandle(info.hProcess);
|
||||
- CloseHandle(info.hThread);
|
||||
-
|
||||
- return done;
|
||||
+ return !done;
|
||||
}
|
||||
|
||||
struct wc_init {
|
||||
@@ -852,9 +854,9 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
||||
{
|
||||
case from_event:
|
||||
/* case of wineconsole <evt>, signal process that created us that we're up and running */
|
||||
- if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend, nCmdShow))) return 0;
|
||||
- ret = SetEvent(wci.event);
|
||||
- if (!ret) WINE_ERR("SetEvent failed.\n");
|
||||
+ if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend, nCmdShow))) return 1;
|
||||
+ ret = !SetEvent(wci.event);
|
||||
+ if (ret != 0) WINE_ERR("SetEvent failed.\n");
|
||||
break;
|
||||
case from_process_name:
|
||||
{
|
||||
@@ -865,30 +867,30 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
||||
|
||||
buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||
if (!buffer)
|
||||
- return 0;
|
||||
+ return 1;
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, len);
|
||||
|
||||
if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow)))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
ret = WINECON_Spawn(data, buffer);
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
- if (!ret)
|
||||
+ if (ret != 0)
|
||||
{
|
||||
WINECON_Delete(data);
|
||||
printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_a(wci.ptr));
|
||||
- return 0;
|
||||
+ return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
- if (ret)
|
||||
+ if (!ret)
|
||||
{
|
||||
WINE_TRACE("calling MainLoop.\n");
|
||||
ret = data->fnMainLoop(data);
|
||||
--
|
||||
2.4.5
|
||||
|
@ -1,12 +1,12 @@
|
||||
From 00afdfb01837f15c91eded183b6f53509d7a9d2d Mon Sep 17 00:00:00 2001
|
||||
From 455d3fe40a00e970a8e31e59c5d88ae671bd6802 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Mon, 13 Jul 2015 02:22:47 +0200
|
||||
Subject: wineconsole: Forward child process exitcode.
|
||||
|
||||
---
|
||||
programs/wineconsole/winecon_private.h | 1 +
|
||||
programs/wineconsole/wineconsole.c | 24 ++++++++++++++++++------
|
||||
2 files changed, 19 insertions(+), 6 deletions(-)
|
||||
programs/wineconsole/wineconsole.c | 17 ++++++++++++++---
|
||||
2 files changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h
|
||||
index 2178dd0..5608f99 100644
|
||||
@ -21,10 +21,10 @@ index 2178dd0..5608f99 100644
|
||||
INT nCmdShow; /* argument of WinMain */
|
||||
BOOL in_set_config; /* to handle re-entrant calls to WINECON_SetConfig */
|
||||
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
|
||||
index ed5f816..a0c8dcf 100644
|
||||
index 4ea5f84..f92632c 100644
|
||||
--- a/programs/wineconsole/wineconsole.c
|
||||
+++ b/programs/wineconsole/wineconsole.c
|
||||
@@ -519,6 +519,7 @@ static void WINECON_Delete(struct inner_data* data)
|
||||
@@ -541,6 +541,7 @@ static void WINECON_Delete(struct inner_data* data)
|
||||
if (data->hConIn) CloseHandle(data->hConIn);
|
||||
if (data->hConOut) CloseHandle(data->hConOut);
|
||||
if (data->hSynchro) CloseHandle(data->hSynchro);
|
||||
@ -32,30 +32,18 @@ index ed5f816..a0c8dcf 100644
|
||||
HeapFree(GetProcessHeap(), 0, data->curcfg.registry);
|
||||
HeapFree(GetProcessHeap(), 0, data->cells);
|
||||
HeapFree(GetProcessHeap(), 0, data);
|
||||
@@ -719,15 +720,16 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
|
||||
@@ -749,7 +750,7 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
|
||||
done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info);
|
||||
if (done)
|
||||
{
|
||||
- CloseHandle(info.hProcess);
|
||||
+ data->hProcess = info.hProcess;
|
||||
CloseHandle(info.hThread);
|
||||
}
|
||||
|
||||
done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info);
|
||||
+ if (done)
|
||||
+ {
|
||||
+ data->hProcess = info.hProcess;
|
||||
+ CloseHandle(info.hThread);
|
||||
+ }
|
||||
@@ -892,8 +893,18 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
||||
|
||||
/* we no longer need the handles passed to the child for the console */
|
||||
CloseHandle(startup.hStdInput);
|
||||
CloseHandle(startup.hStdOutput);
|
||||
CloseHandle(startup.hStdError);
|
||||
-
|
||||
- CloseHandle(info.hProcess);
|
||||
- CloseHandle(info.hThread);
|
||||
-
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -862,8 +864,18 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
||||
|
||||
if (ret)
|
||||
if (!ret)
|
||||
{
|
||||
- WINE_TRACE("calling MainLoop.\n");
|
||||
- ret = data->fnMainLoop(data);
|
||||
@ -64,7 +52,7 @@ index ed5f816..a0c8dcf 100644
|
||||
+ WINE_TRACE("calling MainLoop.\n");
|
||||
+ ret = data->fnMainLoop(data);
|
||||
+
|
||||
+ if (data->hProcess &&
|
||||
+ if (!ret && data->hProcess &&
|
||||
+ WaitForSingleObject(data->hProcess, INFINITE) == WAIT_OBJECT_0 &&
|
||||
+ GetExitCodeProcess(data->hProcess, &exitcode))
|
||||
+ {
|
Loading…
x
Reference in New Issue
Block a user