title: How does linux clean up threads when process exits if they're really just processes under the hood?
body: <p>My understanding is that threads and processes are really the same entity on Linux, the difference being in what memory is shared between them.  I'm finding that it's...difficult to ensure that child processes are properly cleaned up without explicit communication between the parent and child.  I'd like to be able to run sub-processes with a similar mental model as threads, in that they're cleaned up automatically when the parent exits, but with the memory safety that processes provide.  How does Linux manage to clean up threads automatically, and can that same mechanism be used for child processes?</p>