pthread_attr_setstacksize(3) — Subroutines
Digital
NAME
pthread_attr_setstacksize − Changes the stacksize attribute of thread creation.
SYNOPSIS
#include <pthread.h>
int pthread_attr_setstacksize(
pthread_attr_t ∗attr ,
long stacksize );
PARAMETERS
attrThreads attributes object modified.
stacksizeNew value for the stacksize attribute. The stacksize parameter specifies the minimum size (in bytes) of stack needed for a thread.
DESCRIPTION
This routine sets the minimum size (in bytes) of the stack needed for a thread created using the attributes object specified by the attr parameter. Use this routine to adjust the size of the writeable area of the stack. The default value of the stacksize attribute is 60 ∗ 512 bytes (30,720 bytes).
A thread’s stack is fixed at the time of thread creation. Only the main or initial thread can dynamically extend its stack.
Most compilers do not check for stack overflow. Ensure that your thread stack is large enough for anything that you call from the thread.
RETURN VALUES
If an error condition occurs, this routine returns −1 and sets errno to the corresponding error value. Possible return values are as follows:
| Return | Error | Description |
| 0 | Successful completion. | |
| −1 | [EINVAL] | The value specified by attr is invalid. |
| −1 | [ESRCH] | The value specified by attr does not refer to an existing thread attributes object. |
RELATED INFORMATION
pthread_attr_create(3), pthread_attr_getstacksize(3), pthread_create(3)