library/src/threads/BP-LinuxThreads.cc
// returns ERR_SUCCESS if the thread is running, ERR_FAILURE if the thread has exited.  Also marks
// the thread list element to reflect a RUNNING/EXITED message via the structures state member.
returns ERR_SUCCESS if the thread is running, ERR_FAILURE if the thread has exited.  Also marks
the thread list element to reflect a RUNNING/EXITED message via the structures state member.
returns ERR_SUCCESS if the thread is running ERR_FAILURE if the thread has exited . Also marks the thread list element to reflect a RUNNING / EXITED message via the structures state member .
BP_ERROR_T CheckIfThreadIsRunning(P_THREAD_LIST thread_elem)
{
	if(!thread_elem)
	{
		printf("\n [!!] Cannot monitor NULL thread element.  Cannot determine run status of non-existant thread.");
		return ERR_FAILURE;
	}
	if(thread_elem->threadId == 0)
		return ERR_FAILURE;
	if(pthread_kill(thread_elem->threadId, 0) == ESRCH)
	{
		thread_elem->threadState = BP_THREAD_STATUS_EXITED;
		thread_elem->threadId = 0;
		return ERR_FAILURE;
	}
	thread_elem->threadState = BP_THREAD_STATUS_RUNNING;
	return ERR_SUCCESS;
}
BP_ERROR_T CheckIfThreadIsRunning ( P_THREAD_LIST thread_elem ) { if ( ! thread_elem ) { printf ( " \n " ) ; return ERR_FAILURE ; } if ( thread_elem -> threadId == 0 ) return ERR_FAILURE ; if ( pthread_kill ( thread_elem -> threadId , 0 ) == ESRCH ) { thread_elem -> threadState = BP_THREAD_STATUS_EXITED ; thread_elem -> threadId = 0 ; return ERR_FAILURE ; } thread_elem -> threadState = BP_THREAD_STATUS_RUNNING ; return ERR_SUCCESS ; }
returns ERR_SUCCESS if the thread is running, ERR_FAILURE if the thread has exited.
returns ERR_SUCCESS if the thread is running ERR_FAILURE if the thread has exited .
// don't try to check up on ourselves // cannot check a zero thread // Check if the thread cannot be found, if so -- it has exited. // set running flag // return success to indicate that the thread is still running