Re: pthread_join(): any way to limit how long it waits for?




Simon Elliott wrote:
> When a thread exits normally, I want to wait for it to exit, and
> perhaps pick up its status, with pthread_join().
>
> Will there be a race condition if the thread hangs before exiting: will
> pthread_join() wait forever?

No race condition. pthread_join() won't return until the thread
terminates.

> Is there any sensible way to limit the
> time that pthread_join() waits for?

No, just use detached threads and some other means of waiting for a
thread to terminate. Signal a condition, for example, when a thread
terminates, so that you can wait on the condition for a specified
amount of time.

.



Relevant Pages