Skip to main content

emit_exit_event

Function emit_exit_event 

Source
pub fn emit_exit_event(code: i32) -> Result<(), String>
Expand description

Emit process.on('exit', code) exactly once per process, the way Node’s process._exiting latch does — process.exit() inside an exit handler must not re-enter it.

The handlers run SYNCHRONOUSLY and nothing they schedule ever runs: Node leaves the loop straight after them, so a setTimeout or .then queued here is dropped. An exit listener may still raise process.exitCode, and that later value is the one the process uses, which is why the caller reads the slot back after this returns.