thr_set_name(): silently truncate the given name as needed
authorvangyzen <vangyzen@FreeBSD.org>
Sat, 3 Dec 2016 01:14:21 +0000 (01:14 +0000)
committervangyzen <vangyzen@FreeBSD.org>
Sat, 3 Dec 2016 01:14:21 +0000 (01:14 +0000)
commitabbf63d36ba76d2a5154107cb6e138accc39133b
treed20ada1d7b19b1e36a9410d7353f063307500d11
parenta6655c37edc44789c6db5d7e90535cc2cd2701ea
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
lib/libc/sys/thr_set_name.2
share/man/man3/pthread_set_name_np.3
sys/kern/kern_thr.c