Subj : Re: winXP/2k: ExitProcess() & atexit with multiple threads? To : comp.programming.threads From : David Schwartz Date : Wed Feb 16 2005 04:07 am "Mile Blenton" wrote in message news:cuv1lr$p70$1@ls219.htnet.hr... > Recently I've come accross the following behavior when using > ExitProcess() inside addional thread I create within my prg. > > In main thread I attach a function to be called on exit with > atexit() and create an additional thread with CreateThread(). > At some point inside created thread ExitProcess() is called. > > Under winXP (with and without SP1, did not test with SP2), > user atexit function gets called within context of the > running thread (in this case it's the additional thread from > where ExitProcess() is called). > > Under win2000 this is not the case, user atexit function will > not be called when created thread calls ExitProcess, it only > get's called when main thread terminates or calls ExitProcess > (or so it would seem from my test prg). > > > Anyone noticed this and has any explanation of this behavior? > Which beahvior is the right one? > ...or is it just another win wysiwyg feature and should be > accepted as such? :) Neither behavior is required or more correct, as far as I can tell. If you want 'atexit' functions to be run, why not call 'exit'? DS .