Bug in "pthread_mutexattr_setpshared()"

Hi,

I think i might have found a minor bug in “int
pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared)” in
v6.2.1.

The documentation (QNX as well as POSIX) says that the function returns
EINVAL if “The new value specified in pshared isn’t PTHREAD_PROCESS_SHARED
or PTHREAD_PROCESS_PRIVATE”.

However I find that any value I pass for “pshared” is accepted (EOK). Some
testing shows me that odd values equate to PTHREAD_PROCESS_SHARED and even
values are taken as PTHREAD_PROCESS_PRIVATE.

best regards,
Arun.


Test code below:

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>


int
main (int argc, char **argv)
{
pthread_mutexattr_t tAttr;
int iPShared;

pthread_mutexattr_init(&tAttr);

/* argv[1] is the value we want to pass to ‘pshared’.
iPShared = atoi(argv[1]); */

printf("\nAttempting to set ‘pshared’ to %d\n", iPShared);

printf(“Return Value = %s\n”,
(EOK == pthread_mutexattr_setpshared(&tAttr,
iPShared))
? “EOK” : “SOME ERROR”);

pthread_mutexattr_getpshared(&tAttr, &iPShared);
printf(“Retrieved value of ‘pshared’ = %d\n\n”, iPShared);

return 0;
}

Arun,

Thanks for the bug report, it does appear that our documentation is
inconsistent with the behaviour of this function.


Cheers,
-Barry


Arun Annaji wrote:

Hi,

I think i might have found a minor bug in “int
pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared)” in
v6.2.1.

The documentation (QNX as well as POSIX) says that the function returns
EINVAL if “The new value specified in pshared isn’t PTHREAD_PROCESS_SHARED
or PTHREAD_PROCESS_PRIVATE”.

However I find that any value I pass for “pshared” is accepted (EOK). Some
testing shows me that odd values equate to PTHREAD_PROCESS_SHARED and even
values are taken as PTHREAD_PROCESS_PRIVATE.

best regards,
Arun.


Test code below:

#include <pthread.h
#include <stdio.h
#include <stdlib.h
#include <errno.h


int
main (int argc, char **argv)
{
pthread_mutexattr_t tAttr;
int iPShared;

pthread_mutexattr_init(&tAttr);

/* argv[1] is the value we want to pass to ‘pshared’.
iPShared = atoi(argv[1]); */

printf("\nAttempting to set ‘pshared’ to %d\n", iPShared);

printf(“Return Value = %s\n”,
(EOK == pthread_mutexattr_setpshared(&tAttr,
iPShared))
? “EOK” : “SOME ERROR”);

pthread_mutexattr_getpshared(&tAttr, &iPShared);
printf(“Retrieved value of ‘pshared’ = %d\n\n”, iPShared);

return 0;
}