> greetings,
> we shall assume posix threads for the sake of the argument.
> how does one find out if a thread is still running?
> i don't want to do a join, because that will make it stop,
> and i don't want it to stop if it's not done.
No it doesn't. pthread_join() makes the caller wait
until the target thread has terminated. It doesn't do
anything to the target thread.
Quote:> this seems like an obvious thing to do, yet i can't find it,
> and the guy i work with can't find it.
> j.
If all you want to know is whether the thread is still alive,
you can use pthread_kill() to send signal 0 :
if (pthread_kill(tid, 0) == ESRCH)
thread doesn't exist;
else
thread is still alive;
This assumes that 'tid' is still valid. It might not be still
valid if the thread was a detached thread (the tid may have been
reused for a new thread if the old thread exited), or if some
thread has already done a pthread_join() on it, so do this
only on threads that you know are not detached threads that have
not been joined yet.
Roger Faulkner
Sun Microsystems