PTHREAD...TACKSIZE(3POSIX)
β¨ PROLOG β¨
okay bestie so first thing's first: this manual page is part of the POSIX Programmer's Manual. but like, heads up π β the Linux implementation of this interface may differ (so pls go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. no cap.
π 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 it says on the tin, bestie β they get and set the thread creation stacksize attribute inside the attr object. that's it, that's the vibe β¨
the stacksize attribute defines the minimum stack size (in bytes) allocated for the created thread's stack. like, the floor, not the ceiling, iykyk.
β οΈ okay important: 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. don't do that. it's giving chaos π
π RETURN VALUE π
when everything slays and completes successfully, both pthread_attr_getstacksize() and pthread_attr_setstacksize() return a value of 0 π otherwise, an error number gets returned to tell you what went wrong.
and ooh, fun detail: pthread_attr_getstacksize() stores the stacksize attribute value in stacksize if it's successful. so that's where your answer lands π«Ά
π₯ ERRORS π₯
pthread_attr_setstacksize() shall fail if:
EINVALβ the value ofstacksizeis less than{PTHREAD_STACK_MIN}or exceeds a system-imposed limit. like, too tiny or too extra, both get rejected π
these functions shall not return an error code of [EINTR]. periodt.
the following sections are informative. (aka, the lore β¨)
πΈ EXAMPLES πΈ
None. π nothing to see here bestie.
π APPLICATION USAGE π
None. also nothing. iconic of them honestly.
π§ RATIONALE π§
so if an implementation detects that the value specified by the attr argument to pthread_attr_getstacksize() or pthread_attr_setstacksize() does not refer to an initialized thread attributes object, it is recommended that the function should fail and report an [EINVAL] error. like, be polite about it, yk? π
β FUTURE DIRECTIONS β
None. the future is⦠nothing. lowkey peaceful ngl.
π SEE ALSO π
pthread_attr_destroy()pthread_attr_getdetachstate()pthread_create()
The Base Definitions volume of POSIX.1β2017, <limits.h>, <pthread.h> π
π COPYRIGHT π
okay legal era, stay with me π«Ά
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 came from IEEE/The Open Group, dated 2017, and it lives at PTHREAD...TACKSIZE(3POSIX) β go forth and set your stack sizes responsibly, mwah πβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms