NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |STANDARDS |HISTORY |SEE ALSO |COLOPHON | |
pthread_m...etpshared(3) Library Functions Manualpthread_m...etpshared(3)pthread_mutexattr_getpshared, pthread_mutexattr_setpshared - get/set process-shared mutex attribute
POSIX threads library (libpthread,-lpthread)
#include <pthread.h>int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrictattr,int *restrictpshared);int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,intpshared);
These functions get and set the process-shared attribute in a mutex attributes object. This attribute must be appropriately set to ensure correct, efficient operation of a mutex created using this attributes object. The process-shared attribute can have one of the following values:PTHREAD_PROCESS_PRIVATE Mutexes created with this attributes object are to be shared only among threads in the same process that initialized the mutex. This is the default value for the process-shared mutex attribute.PTHREAD_PROCESS_SHARED Mutexes created with this attributes object can be shared between any threads that have access to the memory containing the object, including threads in different processes.pthread_mutexattr_getpshared() places the value of the process- shared attribute of the mutex attributes object referred to byattr in the location pointed to bypshared.pthread_mutexattr_setpshared() sets the value of the process- shared attribute of the mutex attributes object referred to byattr to the value specified inpshared. Ifattr does not refer to an initialized mutex attributes object, the behavior is undefined.
On success, these functions return 0. On error, they return a positive error number.
pthread_mutexattr_setpshared() can fail with the following errors:EINVALThe value specified inpshared is invalid.ENOTSUPpshared isPTHREAD_PROCESS_SHAREDbut the implementation does not support process-shared mutexes.
POSIX.1-2008.
POSIX.1-2001.
pthread_mutexattr_init(3),pthreads(7)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17pthread_m...etpshared(3)Pages that refer to this page:pthread_mutexattr_init(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |