http://qs321.pair.com?node_id=272535


in reply to Change UID for threads?

I suspect you are executing under Linux, and therefore, I do not find the behaviour you are observing to be surprising.

Linux has (until recently) implemented threads as separate processes that share the same file descriptors and memory (among a few other things). This behaviour conflicts with the behaviour for threads defined by POSIX.

More recent thread libraries for Linux, including NPTL honour the POSIX specification much more closely. More recent patches to Linux (some of which are only in the 2.5 stream) modify Linux to work similar to other operating systems (and compatible with POSIX).

In summary, I suggest that you do not rely on this behaviour, unless you wish to enforce that all of the users of your code remain at the version of Linux and GLIBC that you are currently using to perform your tests.

Cheers,
mark