This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: cyg_libc_invoke_atexit_handlers


> From: Andrew Lunn
> 
> Is this something special for main(), or is it generic for 
> all threads?  eCos threads are allowed to exit, since they 
> can be short lived. POSIX probably states that exiting 
> threads run their atexit handlers. So when main() exists its 
> atexit handlers get called.

It's certainly true that returning from "main" should call "exit". In eCos,
this kills the calling thread, and also calls its registered destructors,
which handles stuff specific to that thread. However, the atexit handlers
are global. This means that any atexit handler registered by any thread will
be called whenever any other thread exits, and may even be called multiple
times if multiple threads exit, since cyg_libc_atexit_handlers doesn't
unregister the handlers as they are called.

My guess is that this is something that wasn't thought through, but that no
one ever uses anyway. If that's the case, that's fine with me--I'm just
trying to make sure I'm not missing something important.

Perhaps "atexit" should be replaced with something that registers a thread
destructor.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]