Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - How to check if a thread is alive: (3 Items)
   
How to check if a thread is alive  
I have a process that starts a thread. The thread runs continuously and updates a status variable. My main process does 
several things and checks the status variable set by the thread.  I want to verify the thread is alive before I check 
the status variable. I am not finding the mechanism to check if the thread is running. Can someone point me in the right
 direction?
Re: How to check if a thread is alive  
	ret = pthread_kill(tid, 0);

will return EOK if the thread exists and ESRCH if it doesn't.

On Tue, Sep 14, 2010 at 11:11:17AM -0400, mike gerlach wrote:
> I have a process that starts a thread. The thread runs continuously and updates a status variable. My main process 
does several things and checks the status variable set by the thread.  I want to verify the thread is alive before I 
check the status variable. I am not finding the mechanism to check if the thread is running. Can someone point me in the
 right direction?
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post67187
> 

-- 
Brian Stecher (bstecher@qnx.com)        QNX Software Systems
phone: +1 (613) 591-0931 (voice)        175 Terence Matthews Cr.
       +1 (613) 591-3579 (fax)          Kanata, Ontario, Canada K2M 1W8
Re: How to check if a thread is alive  
I looked at that several times. Thought it would kill the thread. Didn't read enough to see that 0 does nothing. I'll 
try it out, thanks