PTHREAD_A...TSTACKSIZE(3P)
π PTHREAD_A...TSTACKSIZE(3P) π
okay bestie, so this one's from the POSIX Programmer's Manual β¨ (that's the 3P bit in the title, iykyk).
Quick heads up before we dive in: the Linux implementation of this interface may differ from what's written here (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly? the interface might not even be implemented on Linux at all. π Just so you know.
β¨ NAME β¨
pthread_attr_getstacksize, pthread_attr_setstacksize β get and set the stacksize attribute
πΈ SYNOPSIS πΈ
#include <pthread.h>
int pthread_attr_getstacksize(const pthread_attr_t *restrict attr,
size_t *restrict stacksize);
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
π DESCRIPTION π
So pthread_attr_getstacksize() and pthread_attr_setstacksize() do exactly what they sound like: they get and set the thread creation stacksize attribute inside the attr object. Iconic, honestly.
The stacksize attribute defines the minimum stack size (in bytes, fr fr) that gets allocated for the created thread's stack. It's giving "how much room does my girl need to breathe."
π Now the serious bit: the behavior is undefined if the value you pass as theattrargument topthread_attr_getstacksize()orpthread_attr_setstacksize()doesn't refer to an initialized thread attributes object. So like... initialize your stuff. Don't be messy. π«Ά
π RETURN VALUE π
When everything goes slay, both pthread_attr_getstacksize() and pthread_attr_setstacksize() return a value of 0. Otherwise? They hand you an error number to tell you what went wrong. π
And if it works out, pthread_attr_getstacksize() stores the stacksize attribute value in stacksize. No cap. β¨
π₯ ERRORS π₯
The pthread_attr_setstacksize() function shall fail if:
EINVALβ the value ofstacksizeis less than{PTHREAD_STACK_MIN}or it exceeds a system-imposed limit. Basically: too smol or too extra. Pick a normal size bestie. π₯²
β These functions shall not return an error code of [EINTR]. Periodt.
The following sections are informative. (Translation: the juicy technical part is over, these are the bonus features. π)
π EXAMPLES π
None. π Nothing here. Empty. A void. Moving on.
π¦ APPLICATION USAGE π¦
None. Also empty. The girls are giving nothing today, and that's okay. π
π RATIONALE π
So here's the tea: if an implementation detects that the value specified by the attr argument to pthread_attr_getstacksize() or pthread_attr_setstacksize() doesn't refer to an initialized thread attributes object, it is recommended that the function should fail and report an [EINVAL] error. Recommended, not required β so don't come for me if it doesn't. π
π§ FUTURE DIRECTIONS π§
None. β¨ (Iconic of it to have zero plans, honestly.)
π SEE ALSO π
pthread_attr_destroy()pthread_attr_getdetachstate()pthread_create()
The Base Definitions volume of POSIX.1β2017, <limits.h>, <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!! πβ¨ this one's brought to you by IEEE/The Open Group, dated 2017, and it's a certified POSIX Programmer's Manual classic. go forth and stack responsibly π π«Ά
π¦ 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