|
From: Mark W. <ma...@np...> - 2001-09-26 00:13:29
|
>From reading the ReactOS code for ExitThread (lib\kernel32\thread\thread.c),
ExitThread will terminate the process if the thread to exit is the last
thread in the process. AFAIK NT will terminate the process if the first
thread created exits, i.e.
DWORD CALLBACK ThreadProc(LPVOID)
{
while (1) {
Sleep(1000);
}
return 0;
}
int main()
{
DWORD dwThread;
if (!CreateThread(NULL,0,ThreadProc,NULL,0,&dwThread))
printf("No thread: %d\n",GetLastError());
return 0;
}
will just quit. Watching this in the debugger, the spawned thread
terminates with status 0xC000004B (STATUS_THREAD_IS_TERMINATING). I'm not
sure how NT handles this itself, but one way would be to set Spare2 in the
PEB to the ID of the first thread created, check for this in ExitThread()
and call ExitProcess if this is the case. Does this sound sane? Would it
produce the same behaviour (terminate other running threads and clean
shutdown for the main thread?). I'll submit a patch if so, if not, please
advise of a better/more NT friendly method.
Thanks,
Mark
====================================================
= To remove yourself from this mailing list, go to =
= http://www.reactos.com/home/mailing.html =
====================================================
|