Skip to content

Reentrancy

Category: Safety in languages · Status: stub

One line: A function is reentrant if it can be entered again — by another thread, a signal handler, or itself — before an earlier call has finished, usually because it keeps its state in structures the caller owns instead of in statics.

Also called: reentrant function, async-signal-safe.

How it connects

flowchart LR
  n_reentrancy["Reentrancy"]
  n_reentrant_lock["Reentrant lock"]
  n_reentrancy ---|vs| n_reentrant_lock
  classDef center stroke-width:3px
  class n_reentrancy center
  classDef outside stroke-dasharray: 4 3
  class n_reentrant_lock outside

In each language

Python signal: a Python handler does not run inside the low-level C signal handler, which only sets a flag for the interpreter
The operating system signal-safety(7) ↗: an async-signal-safe function is one that can be safely called from within a signal handler

Where to read more