diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 2a20bb1197f0..86df4d7e2f3e 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -407,3 +407,32 @@ thr_wake(struct thread *td, struct thr_wake_args *uap) PROC_UNLOCK(p); return (0); } + +int +thr_set_name(struct thread *td, struct thr_set_name_args *uap) +{ + struct proc *p = td->td_proc; + char name[MAXCOMLEN + 1]; + struct thread *ttd; + int error; + + error = 0; + name[0] = '\0'; + if (uap->name != NULL) { + error = copyinstr(uap->name, name, sizeof(name), + NULL); + if (error) + return (error); + } + PROC_LOCK(p); + if (uap->id == td->td_tid) + ttd = td; + else + ttd = thread_find(p, uap->id); + if (ttd != NULL) + strcpy(ttd->td_name, name); + else + error = ESRCH; + PROC_UNLOCK(p); + return (error); +} diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index aa84a0004843..c8715d9c4481 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -816,5 +816,6 @@ const struct sigevent *sigev); } 462 AUE_NULL MNOSTD { int mq_unlink(const char *path); } 463 AUE_NULL MSTD { int abort2(const char *why, int nargs, void **args); } +464 AUE_NULL MSTD { int thr_set_name(long id, const char *name); } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master diff --git a/sys/sys/thr.h b/sys/sys/thr.h index 155e79bce94f..ce6d53584aa3 100644 --- a/sys/sys/thr.h +++ b/sys/sys/thr.h @@ -60,7 +60,7 @@ void thr_exit(long *state); int thr_kill(long id, int sig); int thr_suspend(const struct timespec *timeout); int thr_wake(long id); - +int thr_set_name(long id, const char *name); #endif /* !_KERNEL */ #endif /* ! _SYS_THR_H_ */