#include <pthread.h> int pthread_attr_getname_np(const pthread_attr_t *attr, char *name);Service Program Name: QP0WPTHR
The pthread_attr_getname_np() function returns the name attribute from the thread attributes object specified. The buffer specified by name must be at least 16 characters in length. The returned thread name will be null terminated in the output buffer.
By default, each thread attributes object is unnamed. If the pthread_attr_setname_np() function has not been used to set the name of the specified thread attributes object, a null string is retrieved into name.
Note: This function is not portable.
None.
If pthread_attr_getname_np() was not successful, the error condition returned usually indicates one of the following errors. Under some conditions, the value returned could indicate an error other than those listed here.
Error condition | Additional information |
---|---|
[EINVAL] |
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#define _MULTI_THREADED #include <pthread.h> #include <stdio.h> #include <string.h> int main(int argc, char **argv) { pthread_attr_t threadAttr; pthread_t thread; int rc=0; char theName[16]; rc = pthread_attr_init(&threadAttr); if (0 != rc) { printf("Error initializing thread attributes - %d\n",rc); return(rc); } memset(theName, 0x00, sizeof(theName)); rc = pthread_attr_setname_np(&threadAttr, "THREADNAMEISTOOLONG"); if(0 == rc) { rc = pthread_attr_getname_np(&threadAttr, theName); if(0 == rc) { printf("The thread attributes object name is %s.\n", theName); } } printf("Main completed\n"); return(rc); }Example Output:
The thread attributes object name is THREADNAMEISTOO. Main completed
[ Back to top | Pthread APIs | APIs by category ]