Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize);
SUSV3
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_attr_getstacksize(const pthread_attr_t * __restrict__attr,
size_t * __restrict__stacksize);
Gets the value, in bytes, of the stacksize attribute for the thread attribute object, attr, that is created by pthread_attr_init(). This function returns the value in the variable pointed to by stacksize.
If successful, pthread_attr_getstacksize() returns 0 and stores the stacksize attribute value in stacksize.
If unsuccessful, pthread_attr_getstacksize() returns -1.
There are no documented errno values. Use perror() or strerror() to determine the cause of the error.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_attr_getstacksize() returns an error number to indicate the error.
⁄* CELEBP08 *⁄
#define _OPEN_THREADS
#include <stdio.h>
#include <pthread.h>
int main()
{
pthread_attr_t attr;
size_t size;
if (pthread_attr_init(&attr) == -1) {
perror("error in pthread_attr_init");
exit(1);
}
if (pthread_attr_getstacksize(&attr, &size) == -1) {
perror("error in pthread_attr_getstackstate()");
exit(2);
}
printf("The stack size is %d.\n", (int) size);
if (pthread_attr_destroy(&attr) == -1) {
perror("error in pthread_attr_destroy");
exit(2);
}
exit(0);
}
The stack size is 524288.