# man > attributes(7)

---
type: CommandReference
command: attributes
mode: man
section: 7
source: man-pages
---

## Quick Reference

- `MT-Safe` — Thread-safe; may not be atomic, but safe with inlining in headers.
- `MT-Unsafe` — Not safe in multithreaded programs.
- `init` — MT‑Unsafe initialization on first call; safe if called once before threading.
- `race` — Data races due to concurrent use of shared objects.
- `const` — Writer non‑atomically modifies an internal “constant” object; protect writers with a read‑write lock.
- `sig` — Temporarily installs a signal handler; avoid conflicting signal uses or hold a mutex.
- `term` — Changes terminal attributes; serialize access with a lock.
- Other remarks (`locale`, `env`, `hostid`, `sigintr`, `cwd`) — Functions reading these data are safe because modifiers are marked `const:` and thus unsafe.

## Name

attributes - POSIX safety concepts

## Synopsis

Safety annotations used in the ATTRIBUTES section of function manual pages.

## Safety Markings

Functions are annotated with:

- `MT-Safe` – Safe to call in the presence of other threads. Being MT‑Safe does not imply atomicity or memory synchronization. Inlining across library interfaces is not recommended; functions defined in user‑visible headers are safe for inlining.

- `MT-Unsafe` – Not safe to call in multithreaded programs.

### Conditionally Safe Features

The following keywords describe specific causes of unsafety and the constraints that remove them:

- `init` – Performs unsafe initialization on first call. Calling the function once in single‑threaded mode removes this cause.

- `race` – Operates on objects in ways that can cause data races. The objects may be user‑supplied (arguments, return values) or internal.

- `const` – Writer non‑atomically modifies internal objects that are otherwise treated as constant. Readers are MT‑Safe (if no other unsafety reasons exist). To call a writer safely: guard all writers with a write lock and all readers with a read lock associated with the identifier that follows `const`.

- `sig` – Temporarily installs a signal handler for internal purposes (the signal is named after a colon, e.g., `sig:signum`). Work around by blocking that signal, calling the function, and restoring the original handler; or hold a non‑recursive mutex across all functions that use the same temporary signal.

- `term` – Changes terminal settings via [`tcgetattr(3)`](http://localhost/phpMan.php/man/tcgetattr/3/markdown) / [`tcsetattr(3)`](http://localhost/phpMan.php/man/tcsetattr/3/markdown), which creates a window where other threads’ changes can be lost. Avoid concurrent use: serialize with a lock that also protects functions marked `race:tcattr(fd)`.

### Other Safety Remarks

The following keywords indicate non‑safety‑critical features that may affect program correctness:

- `locale` – Reads the locale object without synchronization. Safe because locale modifiers are marked `const:locale` and must not be called concurrently.

- `env` – Accesses the environment (e.g., [`getenv(3)`](http://localhost/phpMan.php/man/getenv/3/markdown)) without guards. Safe because environment modifiers are `const:env`.

- `hostid` – Reads the system‑wide host ID ([`gethostid(3)`](http://localhost/phpMan.php/man/gethostid/3/markdown) is safe; [`sethostid(3)`](http://localhost/phpMan.php/man/sethostid/3/markdown) is `const:hostid`).

- `sigintr` – Accesses the internal `__sigintr` structure without guards. Safe because modifiers are `const:sigintr`.

- `cwd` – May temporarily change the current working directory, causing relative pathnames to resolve unexpectedly in other threads or signal handlers. When optional (e.g., [`nftw(3)`](http://localhost/phpMan.php/man/nftw/3/markdown) with `FTW_CHDIR`), consider using absolute paths or `openat(2)` instead.

**Identifiers and conditions**

Annotations may be followed by an identifier (e.g., `:buf(arg)`, `:tcattr(fd)`) to group functions that need the same synchronization. Conditions (e.g., `/!ps`, `/one_per_line`) make a mark conditional on arguments or global state; if all conditions that make a function unsafe are false, the function is safe.

## See Also

[`pthreads(7)`](http://localhost/phpMan.php/man/pthreads/7/markdown), [`signal-safety(7)`](http://localhost/phpMan.php/man/signal-safety/7/markdown)