---
name: "pthread_attr_set_getstacksize"
section: "3"
platform: "macos"
package: "libpthread"
version: "539.100.4"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/pthread_attr_set_getstacksize"
---

# pthread\_attr\_set\_getstacksize(3)

thread attribute operations

## NAME

**pthread\_attr\_getstacksize**, **pthread\_attr\_setstacksize** – thread attribute operations

## 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

Thread attributes are used to specify parameters to **pthread\_create**(). One attribute object can be used in multiple calls to **pthread\_create**(), with or without modifications between calls.

The functions  **pthread\_attr\_setstacksize**() and  **pthread\_attr\_getstacksize**(), respectively, set and get the size of the stack that is to be created for the new thread. The stack size attribute is set within the *attr* argument, which can subsequently be used as an argument to  **pthread\_create**().

## RETURN VALUES

If successful, these functions return 0. Otherwise, an error number is returned to indicate the error.  **pthread\_attr\_getstacksize**() returns the stacksize attribute value in  *stacksize* if successful.

## ERRORS

**pthread\_attr\_getstacksize**() will fail if:

- \[EINVAL\]

  Invalid value for *attr*.

**pthread\_attr\_setstacksize**() will fail if:

- \[EINVAL\]

  Invalid value for *attr*.

- \[EINVAL\]

  *stacksize* is less than PTHREAD\_STACK\_MIN.

- \[EINVAL\]

  *stacksize* is not a multiple of the system page size.

## SEE ALSO

[pthread\_create(3)](/pthread_create/3.md), [pthread\_attr\_init(3)](/pthread_attr_init/3.md), [pthread\_attr\_setstackaddr(3)](/pthread_attr_setstackaddr/3.md)

## STANDARDS

**pthread\_attr\_setstacksize**(), **pthread\_attr\_getstacksize**() conform to ISO/IEC 9945-1:1996 (“POSIX.1”)
