Linux threading bug
A collegue of mine has reported a FreeBSD “bug” that, when the main thread exits, the whole process is terminated. He complained that pthread_detach() would not cause the thread to run without the main thread, while Linux did.
With some experiments we have figured out that this is actually a Linux bug, which violates POSIX. Interestingly, Solaris has the same behavior that FreeBSD have.
The POSIX pthread_create() said:
Note that the thread in which
main()was originally invokeddiffers from this. When it returns frommain(), the effectshall be as if there was an implicit call toexit()usingthe return value ofmain()as the exit status."