_posix_thread_process_shared

This is a discussion on _posix_thread_process_shared within the Linux Programming forums, part of the Platform Specific Boards category; I want to use process-shared POSIX semaphore under UNIX/LINUX. In this FAQ (E.7) , I've found that "Portable applications should ...

_posix_thread_process_shared

I want to use process-shared POSIX semaphore under UNIX/LINUX. In this FAQ (E.7), I've found that "Portable applications should test _POSIX_THREAD_PROCESS_SHARED before using this facility.". Manuals also say, that second parameter (pshared) for sem_init function should be zero, unless this feature is implemented, othrewise sem_init will return ENOSYS.

But that is only theory. I've tested it on my Debian Etch (kernel 2.6.8-2-686, gcc 4.0.2, libc 2.3.6) with this test-program:

Function sem_init returned zero (success, not ENOSYS), but "It's implemented..." text doesn't appear (after removing #ifdef directive, program will not even compile, because " error: '_POSIX_THREAD_PROCESS_SHARED' undeclared (first use in this function)"). I've tried my test-program also on 6.0-STABLE FreeBSD (where manpage says, that "A non-zero value for pshared specifies a shared semaphore that can be used by multiple processes, which this implementation is not capable of."). I've successfuly compiled it, but it's core-dumping when executed.

I've googled out some page discussing this problem, but I do not understand its resolution: "We should not infer any errors beyond those in POSIX.". Also I've found three header files in my filesystem mentioning this constant:
- /usr/include/unistd.h (only comment)

Code:

/* Get values of POSIX options:
If these symbols are defined, the corresponding features are
always available. If not, they may be available sometimes.
The current values can be obtained with `sysconf'.
...
_POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported.
...
If any of these symbols is defined as -1, the corresponding option is not
true for any file. If any is defined as other than -1, the corresponding
option is true for all files. If a symbol is not defined at all, the value
for a specific file can be obtained from `pathconf' and `fpathconf'.
...
*/
#include <bits/posix_opt.h>