Return the proper error code when a 16-bit task failed to start

(thanks to Peter Ganten).
This commit is contained in:
Alexandre Julliard 2000-07-26 18:03:43 +00:00
parent 1f5e43142c
commit 99e1e8106c
1 changed files with 11 additions and 2 deletions

View File

@ -1004,6 +1004,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
TDB *pTask; TDB *pTask;
LPSTR cmdline; LPSTR cmdline;
WORD cmdShow; WORD cmdShow;
HANDLE hThread;
int socket; int socket;
/* Load module */ /* Load module */
@ -1049,7 +1050,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
req->suspend = 0; req->suspend = 0;
req->inherit = 0; req->inherit = 0;
if (server_call_fd( REQ_NEW_THREAD, -1, &socket )) return 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; if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
teb->startup = NE_InitProcess; teb->startup = NE_InitProcess;
@ -1072,7 +1073,14 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
do do
{ {
DirectedYield16( hTask ); 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; if (!(pTask = (TDB *)GlobalLock16( hTask ))) break;
instance = pTask->hInstance; instance = pTask->hInstance;
GlobalUnlock16( hTask ); GlobalUnlock16( hTask );
@ -1083,6 +1091,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
error: error:
/* FIXME: free TEB and task */ /* FIXME: free TEB and task */
close( socket ); close( socket );
CloseHandle( hThread );
return 0; /* FIXME */ return 0; /* FIXME */
} }