pthread

共 1 篇文章。

Linux threading bug

Kernel

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 from main(), the effectshall be as if there was an implicit call to exit() usingthe return value of main() as the exit status."

阅读全文… ( 本文约 161 字,阅读大致需要 1 分钟 )