PTHREAD_R...GETPSHARED(3P)
π PTHREAD_RWLOCKATTR_GETPSHARED, PTHREAD_RWLOCKATTR_SETPSHARED β bestie's guide to the process-shared attribute π¦
okay so real quick before we dive in: this page lives in the POSIX Programmer's Manual (3P, periodt). Heads up though β the Linux implementation of this interface may differ, so if you're on Linux go peek at the corresponding Linux manual page for the actual tea. And lowkey? It might not even be implemented on Linux at all. π So vibe check your platform first.
β¨ NAME β¨
pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared β get and set the process-shared attribute of the read-write lock attributes object π
πΈ SYNOPSIS πΈ
#include <pthread.h>
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t
*restrict attr, int *restrict pshared);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
int pshared);
π DESCRIPTION π
So. pthread_rwlockattr_getpshared() shall go grab the value of the process-shared attribute from the initialized attributes object that attr points at. And pthread_rwlockattr_setpshared() shall set that same process-shared attribute inside the initialized attributes object referenced by attr. One gets, one sets, they're a little duo, iconic. π
Now the important part, no cap: the process-shared attribute shall be set to PTHREAD_PROCESS_SHARED to let a read-write lock be operated upon by any thread that has access to the memory where the read-write lock is allocated β even if that read-write lock lives in memory shared by multiple processes. Like, cross-process besties. π If you wanna know the further requirements, go read Section 2.9.9, Synchronization Object Copies and Alternative Mappings. The default value of the process-shared attribute shall be PTHREAD_PROCESS_PRIVATE.
Additional attributes, their default values, and the names of the associated functions to get and set those attribute values are implementation-defined. So don't come for me, that's just what it says. π€·
β οΈ Behavior is undefined if the value specified by theattrargument topthread_rwlockattr_getpshared()orpthread_rwlockattr_setpshared()does not refer to an initialized read-write lock attributes object. Undefined. Not "kinda weird". Undefined undefined. Do not pass an uninitializedattr, I am begging. π
π«Ά RETURN VALUE π«Ά
Upon successful completion, pthread_rwlockattr_getpshared() shall return zero and store the value of the process-shared attribute of attr into the object referenced by the pshared parameter. Otherwise, an error number shall be returned to indicate the error. (Not errno, bestie β the return value. iykyk.)
If successful, pthread_rwlockattr_setpshared() shall return zero; otherwise, an error number shall be returned to indicate the error.
π ERRORS π
The pthread_rwlockattr_setpshared() function may fail if:
EINVALβ The new value specified for the attribute is outside the range of legal values for that attribute.
These functions shall not return an error code of [EINTR]. Nope. Never. Not on the menu. β
The following sections are informative.
π§ EXAMPLES π§
None.
π APPLICATION USAGE π
None.
π RATIONALE π
None.
β FUTURE DIRECTIONS β
None.
π₯ SEE ALSO π₯
pthread_rwlock_destroy()pthread_rwlockattr_destroy()
The Base Definitions volume of POSIX.1β2017, <pthread.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π mwah π β brought to you by IEEE/The Open Group, 2017 (yes the whole thing is from 2017, we stay timeless). stay slaying, stay initialized, and pls pls pls read Section 2.9.9 before you go sharing locks across processes. π¦β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms