This is the mail archive of the mailing list for the glibc 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: TSD destructors not being called for initial thread

Hi Kaz,

> TSD cleanup for the main thread only makes sense if it calls
> pthread_exit or otherwise terminates in a way that does not take down
> the whole process.
> It therefore doesn't make sense to do it as a part of the global
> process cleanup.
> ... 
> TSD cleanup is designed to prevent resource leaks in programs that
> create and terminate lots of threads; it's not for cleaning up process
> resources. If TSD contains a reference to some resource that has to be
> cleaned up no matter how the process terminates (and is not cleaned up
> automatically by the system), then TSD destructors are not the
> appropriate mechanism to arrange that cleanup.

What you said makes sense, but the spec (SUS) says

  "At thread exit, if a key value has a non-NULL destructor pointer, 
   and the thread has a non-NULL value associated with that key, the 
   value of the key is set to NULL, and then the function pointed to 
   is called with the previously associated value as its sole argument."

Also it never says that this does not apply to the initial thread.

Just in case one argues that the spec is brain-damaged, etc. But then 
one shouldn't call his/her implementation pthread; in for a penny, 
in for a pound...


Attachment: signature.asc
Description: Digital signature

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