wineconsole: Consistently return nonzero exitcode on error.

This commit is contained in:
Sebastian Lackner 2015-07-30 07:34:34 +02:00 committed by Alexandre Julliard
parent 888ffb1134
commit 29b55a5cae
3 changed files with 19 additions and 17 deletions

View file

@ -1018,7 +1018,7 @@ static int WCCURSES_MainLoop(struct inner_data* data)
WCCURSES_Resize(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 ); PRIVATE(data)->input_thread = CreateThread( NULL, 0, input_thread, data, 0, &id );
while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0) while (!data->dying && WaitForSingleObject(data->hSynchro, INFINITE) == WAIT_OBJECT_0)

View file

@ -1382,7 +1382,7 @@ static int WCUSER_MainLoop(struct inner_data* data)
* so GetMessage would lead to delayed processing */ * so GetMessage would lead to delayed processing */
while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) 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); WINE_TRACE("dispatching msg %04x\n", msg.message);
DispatchMessageW(&msg); DispatchMessageW(&msg);
} }

View file

@ -720,7 +720,7 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
* *
* Spawn the child process when invoked with wineconsole foo bar * Spawn the child process when invoked with wineconsole foo bar
*/ */
static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) static int WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
{ {
PROCESS_INFORMATION info; PROCESS_INFORMATION info;
STARTUPINFOW startup; STARTUPINFOW startup;
@ -743,20 +743,22 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine)
{ {
WINE_ERR("Can't dup handles\n"); WINE_ERR("Can't dup handles\n");
/* no need to delete handles, we're exiting the program anyway */ /* no need to delete handles, we're exiting the program anyway */
return FALSE; return 1;
} }
done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info); 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 */ /* we no longer need the handles passed to the child for the console */
CloseHandle(startup.hStdInput); CloseHandle(startup.hStdInput);
CloseHandle(startup.hStdOutput); CloseHandle(startup.hStdOutput);
CloseHandle(startup.hStdError); CloseHandle(startup.hStdError);
CloseHandle(info.hProcess); return !done;
CloseHandle(info.hThread);
return done;
} }
struct wc_init { struct wc_init {
@ -852,9 +854,9 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
{ {
case from_event: case from_event:
/* case of wineconsole <evt>, signal process that created us that we're up and running */ /* 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; if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend, nCmdShow))) return 1;
ret = SetEvent(wci.event); ret = !SetEvent(wci.event);
if (!ret) WINE_ERR("SetEvent failed.\n"); if (ret != 0) WINE_ERR("SetEvent failed.\n");
break; break;
case from_process_name: 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)); buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!buffer) if (!buffer)
return 0; return 1;
MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, len); MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, len);
if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow))) if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow)))
{ {
HeapFree(GetProcessHeap(), 0, buffer); HeapFree(GetProcessHeap(), 0, buffer);
return 0; return 1;
} }
ret = WINECON_Spawn(data, buffer); ret = WINECON_Spawn(data, buffer);
HeapFree(GetProcessHeap(), 0, buffer); HeapFree(GetProcessHeap(), 0, buffer);
if (!ret) if (ret != 0)
{ {
WINECON_Delete(data); WINECON_Delete(data);
printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_a(wci.ptr)); printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_a(wci.ptr));
return 0; return ret;
} }
} }
break; break;
default: default:
return 0; return 1;
} }
if (ret) if (!ret)
{ {
WINE_TRACE("calling MainLoop.\n"); WINE_TRACE("calling MainLoop.\n");
ret = data->fnMainLoop(data); ret = data->fnMainLoop(data);