Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Issues with pthread_cancel(): (2 Items)
   
Issues with pthread_cancel()  
In my application, the main (process) thread creates a detached thread by invoking pthread_create(), storing the thread 
ID in (say) pub_thread. The created thread runs run_publish_thread(), a function that never returns.

Within run_publish_thread(), another detached thread is also created; the thread ID is stored in (say) timer_thread, and
 it runs timeout_thread(). Timeout_thread() basically starts a nanosleep() as fast as possible. So far so good.

The issue starts when the main thread calls pthread_cancel(timer_thread), as timer_thread is still executing the 
nanosleep(). The side effect of calling pthread_cancel() is that *both* pub_thread and timer_thread are being canceled.

I am running QNX 6.3.2 in a x86 target. Any suggestions on run to proceed? Is this expected behavior?

Many thanks for any help you may offer,
- Jefferson
Re: Issues with pthread_cancel()  
My bad. The pub_thread was not being terminated, but blocking in a semaphore. All is working great. Sorry for the noise.


- Jefferson