casper_node/types/exit_code.rs
1use datasize::DataSize;
2use signal_hook::consts::signal::{SIGINT, SIGQUIT, SIGTERM};
3
4/// The offset Rust uses by default when generating an exit code after being interrupted by a
5/// termination signal.
6const SIGNAL_OFFSET: u8 = 128;
7
8/// Exit codes which should be used by the casper-node binary, and provided by the reactor to the
9/// binary.
10///
11/// Note that a panic will result in the Rust process producing an exit code of 101.
12#[derive(Clone, Copy, PartialEq, Eq, Debug, DataSize)]
13#[repr(u8)]
14#[non_exhaustive]
15pub enum ExitCode {
16 /// The process should exit with success. The launcher should proceed to run the next
17 /// installed version of `casper-node`.
18 Success = 0,
19 /// The process should exit with `101`, equivalent to panicking. The launcher should not
20 /// restart the node.
21 Abort = 101,
22 /// The process should exit with `102`. It used to be an indication to the launcher
23 /// that it should proceed to run the previous installed version of `casper-node`.
24 /// It is no longer used, but we keep it here to avoid it being reassigned to other features.
25 #[doc(hidden)]
26 DowngradeVersion = 102,
27 /// The process should exit with `103`. The user requested a node shut down without restart.
28 CleanExitDontRestart = 103,
29 /// The exit code Rust uses by default when interrupted via an `INT` signal.
30 SigInt = SIGNAL_OFFSET + SIGINT as u8,
31 /// The exit code Rust uses by default when interrupted via a `QUIT` signal.
32 SigQuit = SIGNAL_OFFSET + SIGQUIT as u8,
33 /// The exit code Rust uses by default when interrupted via a `TERM` signal.
34 SigTerm = SIGNAL_OFFSET + SIGTERM as u8,
35}