Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Cancelling detached threads (posix threads)?

0
Posted

Cancelling detached threads (posix threads)?

0

Jason Nye wrote: > I’m trying to find out whether the posix specification allows the > cancellation of detached threads. I have a copy of Butenhof’s book and in > the posix mini-reference at the end of the book, he says that pthread_cancel > should fail if the target thread is detached. This makes sense to me, but is > this the correct behaviour? For example LinuxThreads does allow cancellation > of a detached thread — who is correct? This is actually an ambiguity in the standard. An implementation that allows cancellation of a detached thread doesn’t violate the standard. HOWEVER, other provisions of the standard make such an allowance of questionable value, at best. For example, when a detached thread terminates the state of that thread is immediately invalidated, and may be reused immediately for a new thread. At that point (which you cannot determine) you would be cancelling some new thread that you probably didn’t create, with possibly disastrous consequences to your application.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.