Subj : Re: problem with pthread_kill To : comp.programming.threads From : Joe Seigh Date : Sat Jul 16 2005 02:01 pm martinacevedo@gmail.com wrote: > Thank you, but my real problem is that I use a 3th party library(pwlib > with openh323) and in this library there is a function, IsTerminated > and the function uses a pthread_kill for return true or false if thread > is terminated or not, the library handles a lot of thread in c++ > objects wrappers arround the pthread c library functions, and the > program works for 10 hours and then suddenly causes a segmentation > fault. I used a GDB, and the GDB shows that segmentation fault is > caused by the pthread_kill function wihting the PThread object, I know > that the librarie is buggy but I need a partial solution until the fix > of the library appears. > At any rate thank you. > Pthread id's can be reused. The only way to prevent them from being reused is to make them joinable. Otherwise the IsTerminated isn't very reliable. You can keep track thread "termination" by checking when it returns to the start routine assuming it doesn't do a pthread_exit. If that's a problem you can allocate thread specific data and when the thread terminates the destructor for the TSD should run at some point. You can put tracking logic in the TSD destructor. I don't know how you're going to get a partial fix that doesn't involve changing some library code. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .