diff options
author | vangyzen <vangyzen@FreeBSD.org> | 2016-12-13 23:34:07 +0000 |
---|---|---|
committer | vangyzen <vangyzen@FreeBSD.org> | 2016-12-13 23:34:07 +0000 |
commit | f1a55d2a3f0f502f1b9f16b4d166349ecf79664d (patch) | |
tree | 945af3134d118911e02cf4f89d57e705d6f36960 /sys/kern/kern_thr.c | |
parent | 33d63662f28bf596d2c89c3428e2d96264ad6c4c (diff) | |
download | FreeBSD-src-f1a55d2a3f0f502f1b9f16b4d166349ecf79664d.zip FreeBSD-src-f1a55d2a3f0f502f1b9f16b4d166349ecf79664d.tar.gz |
MFC r309460
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.
Sponsored by: Dell EMC
Diffstat (limited to 'sys/kern/kern_thr.c')
-rw-r--r-- | sys/kern/kern_thr.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 1af776c..9458b70 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -579,8 +579,11 @@ sys_thr_set_name(struct thread *td, struct thr_set_name_args *uap) error = 0; name[0] = '\0'; if (uap->name != NULL) { - error = copyinstr(uap->name, name, sizeof(name), - NULL); + error = copyinstr(uap->name, name, sizeof(name), NULL); + if (error == ENAMETOOLONG) { + error = copyin(uap->name, name, sizeof(name) - 1); + name[sizeof(name) - 1] = '\0'; + } if (error) return (error); } |