1.\" $NetBSD: pthread_attr_get_np.3,v 1.5 2017/10/22 15:44:21 abhinav Exp $ 2.\" 3.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi> 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26.\" POSSIBILITY OF SUCH DAMAGE. 27.\" 28.Dd August 6, 2010 29.Dt PTHREAD_ATTR_GET_NP 3 30.Os 31.Sh NAME 32.Nm pthread_attr_get_np , 33.Nm pthread_getattr_np 34.Nd get attributes of existing thread 35.Sh LIBRARY 36.Lb libpthread 37.Sh SYNOPSIS 38.In pthread.h 39.Ft int 40.Fn pthread_attr_get_np "pthread_t thread" "pthread_attr_t *attr" 41.Ft int 42.Fn pthread_getattr_np "pthread_t thread" "pthread_attr_t *attr" 43.Sh DESCRIPTION 44The 45.Fn pthread_attr_get_np 46and 47.Fn pthread_getattr_np 48functions can be used to retrieve attributes of a running 49.Fa thread . 50The result is stored to 51.Fa attr . 52.Pp 53For 54.Fn pthread_attr_get_np 55.Fa attr 56should be initialized prior to the call by using 57.Xr pthread_attr_init 3 . 58.Fn pthread_getattr_np 59does this automatically. 60.Pp 61For both functions 62.Fa attr 63should be freed when it is not in use anymore with 64.Xr pthread_attr_destroy 3 . 65.Pp 66Most fields of 67.Fa attr 68are the same ones provided during thread creation time as a parameter to 69.Xr pthread_create 3 . 70The exceptions include: 71.Bl -bullet -offset indent 72.It 73The detach state -- a joinable thread 74may have detached itself after the creation. 75.It 76The guard size, which may vary if the application 77has allocated its own thread stack. 78.It 79The stack address and size; 80.Fn pthread_attr_get_np 81will always return the thread's real stack address and size, 82regardless of the values in the original attributes structure. 83.El 84.Pp 85The returned 86.Vt pthread_attr_t 87structure is supposed to be used in conjunction with the 88.Fn pthread_attr_get* 89functions to retrieve individual values from the structure. 90When the returned 91.Fa attr 92is no longer needed, it should be destroyed by using 93.Xr pthread_attr_destroy 3 . 94.Sh RETURN VALUES 95Upon successful completion, 96.Fn pthread_attr_get_np 97and 98.Fn pthread_getattr_np 99return 0. 100Otherwise an error number is returned to indicate the error. 101.Sh COMPATIBILITY 102The 103.Fn pthread_attr_get_np 104and 105.Fn pthread_getattr_np 106functions are non-standard extensions. 107.Sh ERRORS 108The 109.Fn pthread_attr_get_np 110and 111.Fn pthread_getattr_np 112functions will fail if: 113.Bl -tag -width Er 114.It Bq Er ENOMEM 115Insufficient memory. 116.It Bq Er ESRCH 117Non-existent 118.Fa thread . 119.El 120.Sh SEE ALSO 121.Xr pthread 3 , 122.Xr pthread_attr 3 123