---
name: "pthread_set_name_np"
section: "3"
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/pthread_get_name_np"
---

# pthread\_set\_name\_np(3)

set and retrieve the thread name

Part of [pthread\_get\_name\_np(3)](/pthread_get_name_np/3.md).

## NAME

**pthread\_get\_name\_np**, **pthread\_getname\_np**, **pthread\_set\_name\_np**, **pthread\_setname\_np** – set and retrieve the thread name

## LIBRARY

POSIX Threads Library (libpthread, -lpthread)

## SYNOPSIS

**#include \<pthread\_np.h\>**

*void*\

**pthread\_get\_name\_np**(*pthread\_t thread*, *char \*name*, *size\_t len*);

*int*\

**pthread\_getname\_np**(*pthread\_t thread*, *char \*name*, *size\_t len*);

*void*\

**pthread\_set\_name\_np**(*pthread\_t thread*, *const char \*name*);

*int*\

**pthread\_setname\_np**(*pthread\_t thread*, *const char \*name*);

## DESCRIPTION

The **pthread\_set\_name\_np**() and **pthread\_setname\_np**() functions apply a copy of the given *name* to the given *thread*.

The **pthread\_get\_name\_np**() and **pthread\_getname\_np**() functions retrieve the *name* associated with *thread*. If **pthread\_set\_name\_np**() was not previously called for *thread*, the buffer pointed to by *name* will be empty.

## ERRORS

The **pthread\_getname\_np** and **pthread\_setname\_np** will fail if

- \[ESRCH\]

  No thread could be found in the current process corresponding to that specified by the given thread ID *thread*.

Because of the debugging nature of **pthread\_get\_name\_np** and **pthread\_set\_name\_np** functions, all errors that may appear inside are silently ignored.

## SEE ALSO

[thr\_set\_name(2)](/thr_set_name/2.md), [pthread\_np(3)](/pthread_np/3.md)

## STANDARDS

**pthread\_set\_name\_np**() and **pthread\_get\_name\_np**() are non-standard extensions. **pthread\_setname\_np**() and **pthread\_getname\_np**() are also non-standard, but are implemented by larger number of operating systems so they are in fact more portable.

## AUTHORS

This manual page was written by Alexey Zelkin ⟨*phantom@FreeBSD.org*⟩ and Yuri Pankov ⟨*yuripv@yuripv.net*⟩.
