1.\" $NetBSD: pthread_attr_get_np.3,v 1.4 2010/08/06 05:35:42 christos 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.Nd get attributes of existing thread 34.Sh LIBRARY 35.Lb libpthread 36.Sh SYNOPSIS 37.In pthread.h 38.Ft int 39.Fn pthread_attr_get_np "pthread_t thread" "pthread_attr_t *attr" 40.Ft int 41.Fn pthread_getattr_np "pthread_t thread" "pthread_attr_t *attr" 42.Sh DESCRIPTION 43The 44.Fn pthread_attr_get_np 45and 46.Fn pthread_getattr_np 47functions can be used to retrieve attributes of a running 48.Fa thread . 49The result is stored to 50.Fa attr . 51.Pp 52For 53.Fn pthread_attr_get_np 54.Fa attr 55should be initialized prior to the call by using 56.Xr pthread_attr_init 3 . 57.Fn pthread_getattr_np 58does this automatically. 59.Pp 60For both functions 61.Fa attr 62should be freed when it is not in use anymore with 63.Xr pthread_attr_destroy 3 . 64.Pp 65Most fields of 66.Fa attr 67are the same ones provided during thread creation time as a parameter to 68.Xr pthread_create 3 . 69The exceptions include: 70.Bl -bullet -offset indent 71.It 72The detach state -- a joinable thread 73may have detached itself after the creation. 74.It 75The guard size, which may vary if the application 76has allocated its own thread stack. 77.It 78The stack address and size; 79.Fn pthread_attr_get_np 80will always return the thread's real stack address and size, 81regardless of the values in the original attributes structure. 82.El 83.Pp 84The returned 85.Vt pthread_attr_t 86structure is supposed to be used in conjunction with the 87.Fn pthread_attr_get* 88functions to retrieve individual values from the structure. 89When the returned 90.Fa attr 91is no longer needed, it should be destroyed by using 92.Xr pthread_attr_destroy 3 . 93.Sh RETURN VALUES 94Upon successful completion, 95.Fn pthread_attr_get_np 96and 97.Fn pthread_getattr_np 98return 0. 99Otherwise an error number is returned to indicate the error. 100.Sh COMPATIBILITY 101The 102.Fn pthread_attr_get_np 103and 104.Fn pthread_getattr_np 105functions are non-standard extensions. 106.Sh ERRORS 107The 108.Fn pthread_attr_get_np 109and 110.Fn pthread_getattr_np 111functions will fail if: 112.Bl -tag -width Er 113.It Bq Er ENOMEM 114Insufficient memory. 115.It Bq Er ESRCH 116Non-existent 117.Fa thread . 118.El 119.Sh SEE ALSO 120.Xr pthread 3 , 121.Xr pthread_attr 3 122