FreeBSD manual
download PDF document: pthread_attr_get_np.3.pdf
PTHREAD_ATTR_GET_NP(3) FreeBSD Library Functions Manual
NAME
pthread_attr_get_np - get attributes of an existing thread
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread_np.h>
int
pthread_attr_get_np(pthread_t pid, pthread_attr_t *dst);
DESCRIPTION
The pthread_attr_get_np() function is used to retrieve the attributes of
the specified thread into an existing pthread_attr_t structure. The
attributes' values are the current ones for the target thread, except for
the stack top address if not properly aligned for the architecture, since
in this case its value has been adjusted internally before use.
Argument dst must be a pointer to a valid attributes object (it was
initialized at some point by pthread_attr_init(3) and was not destroyed
since then). After a successful call to pthread_attr_get_np(), the
individual attributes' values can be retrieved as usual via the
corresponding accessor functions as documented in pthread_attr(3). After
a failed call to pthread_attr_get_np(), the object pointed to by dst is
left unmodified, and can continue to be used as if the failed call never
happened.
RETURN VALUES
If successful, pthread_attr_get_np() function returns 0. Otherwise, an
error number is returned to indicate the error.
EXAMPLES
This function retrieves the stack size of the thread specified by the pid
argument:
size_t
my_thread_stack_size(pthread_t tid)
{
pthread_attr_t attr;
size_t size;
pthread_attr_init(&attr);
pthread_attr_get_np(tid, &attr);
pthread_attr_getstacksize(&attr, &size);
pthread_attr_destroy(&attr);
return (size);
}
ERRORS
The pthread_attr_get_np() function will fail if:
[EINVAL] One of the arguments has an invalid value.
[ESRCH] No thread could be found corresponding to that
specified by the given thread ID.
pthread_attr_getschedpolicy(3), pthread_attr_getscope(3),
pthread_attr_getstack(3), pthread_attr_getstackaddr(3),
pthread_attr_getstacksize(3), pthread_attr_init(3), pthread_np(3)
AUTHORS
The pthread_attr_get_np() function and this manual page were written by
Alexey Zelkin <phantom@FreeBSD.org>, and the latter was revised by
Olivier Certner <olce@FreeBSD.org>.
FreeBSD 14.2-RELEASE January 5, 2024 FreeBSD 14.2-RELEASE