aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/thr_set_name.2
diff options
context:
space:
mode:
authorEric van Gyzen <vangyzen@FreeBSD.org>2016-12-03 01:14:21 +0000
committerEric van Gyzen <vangyzen@FreeBSD.org>2016-12-03 01:14:21 +0000
commitff07dd913e2788f22cf2999f42b8a2d3bc7da220 (patch)
treed20ada1d7b19b1e36a9410d7353f063307500d11 /lib/libc/sys/thr_set_name.2
parent86bd08e9ee24812240e144fba570f88d31dd0b97 (diff)
downloadsrc-ff07dd913e2788f22cf2999f42b8a2d3bc7da220.tar.gz
src-ff07dd913e2788f22cf2999f42b8a2d3bc7da220.zip
thr_set_name(): silently truncate the given name as needed
Instead of failing with ENAMETOOLONG, which is swallowed by pthread_set_name_np() anyway, truncate the given name to MAXCOMLEN+1 bytes. This is more likely what the user wants, and saves the caller from truncating it before the call (which was the only recourse). Polish pthread_set_name_np(3) and add a .Xr to thr_set_name(2) so the user might find the documentation for this behavior. Reviewed by: jilles MFC after: 3 days Sponsored by: Dell EMC
Notes
Notes: svn path=/head/; revision=309460
Diffstat (limited to 'lib/libc/sys/thr_set_name.2')
-rw-r--r--lib/libc/sys/thr_set_name.225
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/libc/sys/thr_set_name.2 b/lib/libc/sys/thr_set_name.2
index d2549e408cb6..a83e53109491 100644
--- a/lib/libc/sys/thr_set_name.2
+++ b/lib/libc/sys/thr_set_name.2
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 1, 2016
+.Dd December 2, 2016
.Dt THR_SET_NAME 2
.Os
.Sh NAME
@@ -43,37 +43,34 @@
.Sh DESCRIPTION
The
.Fn thr_set_name
-sets the user-visible name for the kernel thread with the identifier
+system call sets the user-visible name for the thread with the identifier
.Va id
-in the current process, to the NUL-terminated string
+in the current process to the NUL-terminated string
.Va name .
+The name will be silently truncated to fit into a buffer of
+.Dv MAXCOMLEN + 1
+bytes.
The thread name can be seen in the output of the
.Xr ps 1
and
.Xr top 1
commands, in the kernel debuggers and kernel tracing facility outputs,
-also in userland debuggers and program core files, as notes.
+and in userland debuggers and program core files, as notes.
.Sh RETURN VALUES
If successful,
.Fn thr_set_name
-will return zero, otherwise \-1 is returned, and
+returns zero; otherwise, \-1 is returned, and
.Va errno
is set to indicate the error.
.Sh ERRORS
The
.Fn thr_set_name
-operation may return the following errors:
+system call may return the following errors:
.Bl -tag -width Er
.It Bq Er EFAULT
The memory pointed to by the
.Fa name
argument is not valid.
-.It Bq Er ENAMETOOLONG
-The string pointed to by the
-.Fa name
-argument exceeds
-.Dv MAXCOMLEN + 1
-bytes in length.
.It Bq Er ESRCH
The thread with the identifier
.Fa id
@@ -92,6 +89,6 @@ does not exist in the current process.
.Xr ktr 9
.Sh STANDARDS
The
-.Fn thr_new
-system call is non-standard and is used by
+.Fn thr_set_name
+system call is non-standard and is used by the
.Lb libthr .