Reputation: 17268
Given only thread id, is it possible to decide from there whether the thread is still alive or not? I'm talking about C++ on linux.
Upvotes: 1
Views: 1722
Reputation: 67733
From the manpage:
DESCRIPTION
The pthread_kill() function shall request that a signal be deliv- ered to the specified thread. As in kill(), if sig is zero, error checking shall be performed but no signal shall actually be sent.
so:
bool isalive(int threadid)
{
return pthread_kill(threadid, 0) != ESRCH;
}
Upvotes: 5