The thread model join and the process model wait

By now, you should have begun to realize that although the pthread_join(3) and wait(2) (and family) APIs seem to be very similar, they are certainly not equivalent; several differences between them exist and are enumerated in the following table:

Situation

Thread : pthread_join(3)

Process: wait[pid](2)

Condition

A thread being waited for must have its detached state attribute set as joinable, not detached.

None; any child process can (and in fact must) be waited upon (recall our fork rule #7)

Hierarchy

None: any thread can join on any other thread; there is no requirement of a parent-child relationship. In fact, we do not consider threads to live within a strict parent-child ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.