=?UTF-8?Q?Michael=20M=C3=BCller=20?=: wineconsole: Forward child process exitcode.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Oct 1 10:57:00 CDT 2015


Module: wine
Branch: master
Commit: 5d4a9617898c898e9e095ee11d9430fcb48b27e3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5d4a9617898c898e9e095ee11d9430fcb48b27e3

Author: Michael Müller <michael at fds-team.de>
Date:   Thu Sep 24 04:34:57 2015 +0200

wineconsole: Forward child process exitcode.

Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>

---

 programs/wineconsole/winecon_private.h |  1 +
 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
--- a/programs/wineconsole/winecon_private.h
+++ b/programs/wineconsole/winecon_private.h
@@ -59,6 +59,7 @@ struct inner_data {
     HANDLE		hConIn;		/* console input handle */
     HANDLE		hConOut;	/* screen buffer handle: has to be changed when active sb changes */
     HANDLE		hSynchro;	/* waitable handle signalled by server when something in server has been modified */
+    HANDLE              hProcess;       /* handle to the child process or NULL */
     HWND		hWnd;           /* handle of 'user' window or NULL for 'curses' */
     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 b8b517a..e1ee55b 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -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);
+    if (data->hProcess)         CloseHandle(data->hProcess);
     HeapFree(GetProcessHeap(), 0, data->curcfg.registry);
     HeapFree(GetProcessHeap(), 0, data->cells);
     HeapFree(GetProcessHeap(), 0, data);
@@ -749,7 +750,7 @@ static int 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);
     }
 
@@ -892,8 +893,18 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
 
     if (!ret)
     {
-	WINE_TRACE("calling MainLoop.\n");
-	ret = data->fnMainLoop(data);
+        DWORD exitcode;
+
+        WINE_TRACE("calling MainLoop.\n");
+        ret = data->fnMainLoop(data);
+
+        if (!ret && data->hProcess &&
+            WaitForSingleObject(data->hProcess, INFINITE) == WAIT_OBJECT_0 &&
+            GetExitCodeProcess(data->hProcess, &exitcode))
+        {
+            WINE_TRACE("forwarding exitcode %u from child process\n", exitcode);
+            ret = exitcode;
+        }
     }
 
     WINECON_Delete(data);




More information about the wine-cvs mailing list