| 1 |
.\" Copyright 2017, Michael Kerrisk <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH pthread_mutexattr_getpshared 3 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
pthread_mutexattr_getpshared, pthread_mutexattr_setpshared \- get/set |
| 9 |
process-shared mutex attribute |
| 10 |
.SH LIBRARY |
| 11 |
POSIX threads library |
| 12 |
.RI ( libpthread ,\~ \-lpthread ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <pthread.h> |
| 16 |
.P |
| 17 |
.B int pthread_mutexattr_getpshared( |
| 18 |
.BI " const pthread_mutexattr_t *restrict " attr , |
| 19 |
.BI " int *restrict " pshared ); |
| 20 |
.BI "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr , |
| 21 |
.BI " int " pshared ); |
| 22 |
.fi |
| 23 |
.SH DESCRIPTION |
| 24 |
These functions get and set the process-shared attribute |
| 25 |
in a mutex attributes object. |
| 26 |
This attribute must be appropriately set to ensure correct, |
| 27 |
efficient operation of a mutex created using this attributes object. |
| 28 |
.P |
| 29 |
The process-shared attribute can have one of the following values: |
| 30 |
.TP |
| 31 |
.B PTHREAD_PROCESS_PRIVATE |
| 32 |
Mutexes created with this attributes object are to be shared |
| 33 |
only among threads in the same process that initialized the mutex. |
| 34 |
This is the default value for the process-shared mutex attribute. |
| 35 |
.TP |
| 36 |
.B PTHREAD_PROCESS_SHARED |
| 37 |
Mutexes created with this attributes object can be shared between |
| 38 |
any threads that have access to the memory containing the object, |
| 39 |
including threads in different processes. |
| 40 |
.P |
| 41 |
.BR pthread_mutexattr_getpshared () |
| 42 |
places the value of the process-shared attribute of |
| 43 |
the mutex attributes object referred to by |
| 44 |
.I attr |
| 45 |
in the location pointed to by |
| 46 |
.IR pshared . |
| 47 |
.P |
| 48 |
.BR pthread_mutexattr_setpshared () |
| 49 |
sets the value of the process-shared attribute of |
| 50 |
the mutex attributes object referred to by |
| 51 |
.I attr |
| 52 |
to the value specified in |
| 53 |
.BR pshared . |
| 54 |
.P |
| 55 |
If |
| 56 |
.I attr |
| 57 |
does not refer to an initialized mutex attributes object, |
| 58 |
the behavior is undefined. |
| 59 |
.SH RETURN VALUE |
| 60 |
On success, these functions return 0. |
| 61 |
On error, they return a positive error number. |
| 62 |
.SH ERRORS |
| 63 |
.BR pthread_mutexattr_setpshared () |
| 64 |
can fail with the following errors: |
| 65 |
.TP |
| 66 |
.B EINVAL |
| 67 |
The value specified in |
| 68 |
.I pshared |
| 69 |
is invalid. |
| 70 |
.TP |
| 71 |
.B ENOTSUP |
| 72 |
.I pshared |
| 73 |
is |
| 74 |
.B PTHREAD_PROCESS_SHARED |
| 75 |
but the implementation does not support process-shared mutexes. |
| 76 |
.SH STANDARDS |
| 77 |
POSIX.1-2008. |
| 78 |
.SH HISTORY |
| 79 |
POSIX.1-2001. |
| 80 |
.SH SEE ALSO |
| 81 |
.ad l |
| 82 |
.nh |
| 83 |
.BR pthread_mutexattr_init (3), |
| 84 |
.BR pthreads (7) |