Till recently, I was under the impression that if you \"detach\" a thread after spawning it, the thread lives even after the \"main\" thread terminates.
But a litt
pthread_detach just means that you are never going to join with the thread again. This allows the pthread library to know whether it can immediately dispose of the thread resources once the thread exits (the detached case) or whether it must keep them around because you may later call pthread_join on the thread.
Once main returns (or exits) the OS will reap all your threads and destroy your process.