Skip to main content

FORKLEVEL

Static FORKLEVEL 

Source
pub static FORKLEVEL: AtomicI32
Expand description

Port of int forklevel; from Src/exec.c:1052. Records the locallevel at the most recent fork point (set at c:1221: forklevel = locallevel; inside entersubsh()). Used by:

  • signals.c:808 SIGPIPE handler — !forklevel distinguishes the top-level shell from a forked subshell.
  • exec.c:6146if (locallevel > forklevel) decides whether a function-defined trap should fire on this subshell exit.
  • params.c:3724 — WARNCREATEGLOBAL nest-depth check.

Initialised to 0 (no fork has occurred yet). Set to locallevel at every entersubsh() entry per c:1221.