expression
Choose a documented interruption exit policy
A cooperative shutdown should return a documented nonzero status when the requested job was interrupted. The value 130 is a conventional shell-style choice for SIGINT, not a portable law or proof of actual signal delivery. This example simulates interruption after cleanup, without emitting OS signals. Fixture: Expected stdout (not executed): (empty) Expected stderr: 'interrupted; unpublished work discarded\n' Expected exit: 130 Common mistake: Calling process::exit before cleanup or treating all signals as recoverable.
Formal Syntax & Structure
rust syntaxrust
ExitCode::from(130)Working Example
Example Snippetrust
fn main() -> std::process::ExitCode { use std::process::ExitCode; let interrupted = true; if interrupted { eprintln!("interrupted; unpublished work discarded"); ExitCode::from(130) } else { ExitCode::SUCCESS }}