xref: /illumos-gate/usr/src/man/man3c/pthread_getname_np.3c (revision ab618543cc6fc4bc273c077ef5d247961cdb29d4)
1*ab618543SJohn Levon.\"
2*ab618543SJohn Levon.\" This file and its contents are supplied under the terms of the
3*ab618543SJohn Levon.\" Common Development and Distribution License ("CDDL"), version 1.0.
4*ab618543SJohn Levon.\" You may only use this file in accordance with the terms of version
5*ab618543SJohn Levon.\" 1.0 of the CDDL.
6*ab618543SJohn Levon.\"
7*ab618543SJohn Levon.\" A full copy of the text of the CDDL should have accompanied this
8*ab618543SJohn Levon.\" source.  A copy of the CDDL is also available via the Internet at
9*ab618543SJohn Levon.\" http://www.illumos.org/license/CDDL.
10*ab618543SJohn Levon.\"
11*ab618543SJohn Levon.\"
12*ab618543SJohn Levon.\" Copyright 2018 Joyent, Inc.
13*ab618543SJohn Levon.\"
14*ab618543SJohn Levon.Dd "August 22, 2018"
15*ab618543SJohn Levon.Dt PTHREAD_GETNAME_NP 3C
16*ab618543SJohn Levon.Os
17*ab618543SJohn Levon.Sh NAME
18*ab618543SJohn Levon.Nm pthread_getname_np ,
19*ab618543SJohn Levon.Nm pthread_setname_np
20*ab618543SJohn Levon.Nd get or set the name of a thread
21*ab618543SJohn Levon.Sh SYNOPSIS
22*ab618543SJohn Levon.In pthread.h
23*ab618543SJohn Levon.
24*ab618543SJohn Levon.Ft int
25*ab618543SJohn Levon.Fo pthread_getname_np
26*ab618543SJohn Levon.Fa "pthread_t tid"
27*ab618543SJohn Levon.Fa "char *name"
28*ab618543SJohn Levon.Fa "size_t len"
29*ab618543SJohn Levon.Fc
30*ab618543SJohn Levon.
31*ab618543SJohn Levon.Ft int
32*ab618543SJohn Levon.Fo pthread_setname_np
33*ab618543SJohn Levon.Fa "pthread_t tid"
34*ab618543SJohn Levon.Fa "const char *name"
35*ab618543SJohn Levon.Fc
36*ab618543SJohn Levon.
37*ab618543SJohn Levon.Sh DESCRIPTION
38*ab618543SJohn LevonThe
39*ab618543SJohn Levon.Fn pthread_getname_np
40*ab618543SJohn Levonand
41*ab618543SJohn Levon.Fn pthread_setname_np
42*ab618543SJohn Levonfunctions, respectively, get and set the names of the thread whose id is given
43*ab618543SJohn Levonby the
44*ab618543SJohn Levon.Fa tid
45*ab618543SJohn Levonparameter.
46*ab618543SJohn LevonFor
47*ab618543SJohn Levon.Fn pthread_getname_np ,
48*ab618543SJohn Levon.Fa len
49*ab618543SJohn Levonindicates the size of
50*ab618543SJohn Levon.Fa name .
51*ab618543SJohn Levon.Pp
52*ab618543SJohn LevonThread names are limited to
53*ab618543SJohn Levon.Dv PTHREAD_MAX_NAMELEN_NP
54*ab618543SJohn Levonincluding the terminating NUL.
55*ab618543SJohn LevonThey may only contain printable ASCII characters.
56*ab618543SJohn Levon.Pp
57*ab618543SJohn LevonTo clear a thread name, call
58*ab618543SJohn Levon.Fn pthread_setname_np
59*ab618543SJohn Levonwith
60*ab618543SJohn Levon.Sy NULL .
61*ab618543SJohn Levon.Pp
62*ab618543SJohn LevonUnlike some other systems, threads do not inherit the process name by default.
63*ab618543SJohn Levon.Sh RETURN VALUES
64*ab618543SJohn LevonUpon successful completion, the
65*ab618543SJohn Levon.Fn pthread_getname_np
66*ab618543SJohn Levonand
67*ab618543SJohn Levon.Fn pthread_setname_np
68*ab618543SJohn Levonfunctions return
69*ab618543SJohn Levon.Sy 0 .
70*ab618543SJohn LevonOtherwise, an error number is returned to indicate the error.
71*ab618543SJohn LevonIf the thread identified by
72*ab618543SJohn Levon.Fa tid
73*ab618543SJohn Levondoes not have a name set,
74*ab618543SJohn Levon.Fa pthread_getname_np
75*ab618543SJohn Levonwill be set to an empty string (length = 0).
76*ab618543SJohn Levon.Sh ERRORS
77*ab618543SJohn LevonOn failure, the contents of the buffer are undefined.
78*ab618543SJohn LevonErrors from
79*ab618543SJohn Levon.Xr open 2 ,
80*ab618543SJohn Levon.Xr read 2 ,
81*ab618543SJohn Levonor
82*ab618543SJohn Levon.Xr write 2
83*ab618543SJohn Levonare possible.
84*ab618543SJohn LevonIn addition, the
85*ab618543SJohn Levon.Fn pthread_getname_np
86*ab618543SJohn Levonfunction will fail with:
87*ab618543SJohn Levon.Bl -tag -width Er
88*ab618543SJohn Levon.It Er EINVAL
89*ab618543SJohn LevonThe
90*ab618543SJohn Levon.Fa name
91*ab618543SJohn Levonargument is
92*ab618543SJohn Levon.Sy NULL .
93*ab618543SJohn Levon.It Er ERANGE
94*ab618543SJohn LevonThe size of
95*ab618543SJohn Levon.Fa name
96*ab618543SJohn Levonas given by
97*ab618543SJohn Levon.Fa len
98*ab618543SJohn Levonwas not large enough to contain the name of the thread.
99*ab618543SJohn Levon.It Er ESRCH
100*ab618543SJohn LevonThe thread
101*ab618543SJohn Levon.Fa tid
102*ab618543SJohn Levonwas not found.
103*ab618543SJohn Levon.El
104*ab618543SJohn Levon.Pp
105*ab618543SJohn LevonThe
106*ab618543SJohn Levon.Fn pthread_setname_np
107*ab618543SJohn Levonfunction will fail with:
108*ab618543SJohn Levon.Bl -tag -width Er
109*ab618543SJohn Levon.It Er ERANGE
110*ab618543SJohn LevonThe length of
111*ab618543SJohn Levon.Fa name
112*ab618543SJohn Levonexceeds the maximum allowed size.
113*ab618543SJohn Levon.It Er ESRCH
114*ab618543SJohn LevonThe thread
115*ab618543SJohn Levon.Fa tid
116*ab618543SJohn Levonwas not found.
117*ab618543SJohn Levon.El
118*ab618543SJohn Levon.Sh INTERFACE STABILITY
119*ab618543SJohn Levon.Sy Uncommitted
120*ab618543SJohn Levon.Sh MT-LEVEL
121*ab618543SJohn Levon.Sy MT-Safe
122*ab618543SJohn Levon.Sh SEE ALSO
123*ab618543SJohn Levon.Xr pthread_attr_getname_np 3c ,
124*ab618543SJohn Levon.Xr pthread_create 3c
125