---
name: "thr_set_name"
section: "2"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/thr_set_name"
---

# thr\_set\_name(2)

set user-visible thread name

## NAME

**thr\_set\_name** – set user-visible thread name

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/thr.h\>**

*int*\

**thr\_set\_name**(*long id*, *const char \*name*);

## DESCRIPTION

The **thr\_set\_name**() system call sets the user-visible name for the thread with the identifier *id* in the current process to the NUL-terminated string *name*. The name will be silently truncated to fit into a buffer of MAXCOMLEN + 1 bytes. The thread name can be seen in the output of the [ps(1)](/ps/1.md) and [top(1)](/top/1.md) commands, in the kernel debuggers and kernel tracing facility outputs, and in userland debuggers and program core files, as notes.

## RETURN VALUES

If successful, **thr\_set\_name**() returns zero; otherwise, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

The **thr\_set\_name**() system call may return the following errors:

- \[EFAULT\]

  The memory pointed to by the *name* argument is not valid.

- \[ESRCH\]

  The thread with the identifier *id* does not exist in the current process.

## SEE ALSO

[ps(1)](/ps/1.md), [\_umtx\_op(2)](/_umtx_op/2.md), [thr\_exit(2)](/thr_exit/2.md), [thr\_kill(2)](/thr_kill/2.md), [thr\_kill2(2)](/thr_kill2/2.md), [thr\_new(2)](/thr_new/2.md), [thr\_self(2)](/thr_self/2.md), [pthread\_set\_name\_np(3)](/pthread_set_name_np/3.md), [ddb(4)](/ddb/4.md), [ktr(9)](/ktr/9.md)

## STANDARDS

The **thr\_set\_name**() system call is non-standard and is used by the library “libthr”.

## HISTORY

The **thr\_set\_name**() system call first appeared in FreeBSD 5.2.
