From 99e1e8106c53ffcfb57f6377fd9bac72a87681ed Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 26 Jul 2000 18:03:43 +0000 Subject: [PATCH] Return the proper error code when a 16-bit task failed to start (thanks to Peter Ganten). --- loader/ne/module.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/loader/ne/module.c b/loader/ne/module.c index 5d2bb07d2eb..a5293345abc 100644 --- a/loader/ne/module.c +++ b/loader/ne/module.c @@ -1004,6 +1004,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) TDB *pTask; LPSTR cmdline; WORD cmdShow; + HANDLE hThread; int socket; /* Load module */ @@ -1049,7 +1050,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) req->suspend = 0; req->inherit = 0; if (server_call_fd( REQ_NEW_THREAD, -1, &socket )) return 0; - CloseHandle( req->handle ); + hThread = req->handle; if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error; teb->startup = NE_InitProcess; @@ -1072,7 +1073,14 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) do { DirectedYield16( hTask ); - if (!IsTask16( hTask )) break; + if (!IsTask16( hTask )) /* thread has died */ + { + DWORD exit_code; + WaitForSingleObject( hThread, INFINITE ); + GetExitCodeThread( hThread, &exit_code ); + CloseHandle( hThread ); + return exit_code; + } if (!(pTask = (TDB *)GlobalLock16( hTask ))) break; instance = pTask->hInstance; GlobalUnlock16( hTask ); @@ -1083,6 +1091,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock ) error: /* FIXME: free TEB and task */ close( socket ); + CloseHandle( hThread ); return 0; /* FIXME */ }