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
To quote the Linux Programmer's Manual:
The detached attribute merely determines the behavior of the system when the thread terminates; it does not prevent the thread from being terminated if the process terminates using
exit(3)(or equivalently, if the main thread returns).
Also from the Linux Programmer's Manual:
To allow other threads to continue execution, the main thread should terminate by calling
pthread_exit()rather thanexit(3).