Cancelling pthread_join() DOESNT detach target thread?
Alexander Terekhov wrote: > the standard says: > > “Cancelation Points > > Cancelation points shall occur when a thread is > executing the following functions: > . > . > . > pthread_join()…” > > “If the thread calling pthread_join() is canceled, > then the target thread shall not be detached.” > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Q) WHY ??? This is, as you guessed below, a requirement for the IMPLEMENTATION. What it means is perhaps a little complicated, and this is one of the reasons that the STANDARD isn’t really intended as general user documentation. Part of the confusion is historical, and would be more obvious to someone familiar with DCE threads, which was an implementation of an early draft of the standard document. Originally, “detach” and “join” were separate operations. “Join” merely allowed a thread to wait until the target was complete. There was no reason that both threads 1 and 2 couldn’t wait for thread 3 to complete. But in order to ensure that system resources