1 .\"
   2 .\" This file and its contents are supplied under the terms of the
   3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
   4 .\" You may only use this file in accordance with the terms of version
   5 .\" 1.0 of the CDDL.
   6 .\"
   7 .\" A full copy of the text of the CDDL should have accompanied this
   8 .\" source.  A copy of the CDDL is also available via the Internet at
   9 .\" http://www.illumos.org/license/CDDL.
  10 .\"
  11 .\"
  12 .\" Copyright 2018 Joyent, Inc.
  13 .\"
  14 .Dd August 31, 2018
  15 .Dt PLWP_GETNAME 3PROC
  16 .Os
  17 .Sh NAME
  18 .Nm Plwp_getname
  19 .Nd get thread name
  20 .Sh LIBRARY
  21 .Lb libproc
  22 .Sh SYNOPSIS
  23 .In libproc.h
  24 .Ft int
  25 .Fo Plwp_getname
  26 .Fa "struct ps_prochandle *P"
  27 .Fa "lwpid_t lwpid"
  28 .Fa "char *buf"
  29 .Fa "size_t bufsize"
  30 .Fc
  31 .Sh DESCRIPTION
  32 The
  33 .Fn Plwp_getname
  34 function returns the thread name in the supplied buffer, from the
  35 thread
  36 .Fa lwpid
  37 in the process handle
  38 .Fa P .
  39 .Pp
  40 If no thread name is set, the buffer is set to the empty string.
  41 The buffer should be at least
  42 .Dv THREAD_NAME_MAX
  43 in size.
  44 .Pp
  45 The
  46 .Fn Plwp_getname
  47 function only works on process handles that refer to active processes
  48 and core files, it does not work on process handles that refer to
  49 individual files.
  50 .Sh RETURN VALUES
  51 Upon successful completion, the
  52 .Fn Plwp_getname
  53 function returns 0.
  54 Otherwise,
  55 .Sy -1
  56 is returned,
  57 .Sy errno
  58 is set to indicate the error.
  59 The buffer may be modified even if an error is returned.
  60 .Sh ERRORS
  61 For a full list of possible errors also see the
  62 .Sy DIAGNOSTICS
  63 section in
  64 .Xr proc 4 .
  65 .Pp
  66 The
  67 .Fn Plwp_getname
  68 function will fail if:
  69 .Bl -tag -width Er
  70 .It Er ENODATA
  71 .Fa P
  72 refers to a file handle obtained through
  73 .Xr Pgrab_file 3PROC .
  74 .It Er EINVAL
  75 The process handle
  76 .Fa P
  77 refers to a core file and the specified thread does not exist.
  78 .It Er ENOENT
  79 The process handle
  80 .Fa P
  81 refers to an active process and the specified thread does not exist.
  82 .Fa P
  83 .It Er ENAMETOOLONG
  84 The buffer is not sufficient to hold the thread name.
  85 .El
  86 .Sh INTERFACE STABILITY
  87 .Sy Uncommitted
  88 .Sh MT-LEVEL
  89 See
  90 .Sy LOCKING
  91 in
  92 .Xr libproc 3LIB .
  93 .Sh SEE ALSO
  94 .Xr libproc 3LIB ,
  95 .Xr proc 4