提交 37888d66 authored 作者: Serhij S's avatar Serhij S

critical exception

上级 4c239b3b
[package]
name = "roboplc"
version = "0.1.33"
version = "0.1.34"
edition = "2021"
authors = ["Serhij S. <div@altertech.com>"]
license = "Apache-2.0"
......
......@@ -3,6 +3,7 @@ use core::{fmt, num};
use std::io::Write;
use std::{env, mem, str::FromStr, sync::Arc, time::Duration};
use colored::Colorize as _;
use thread_rt::{RTParams, Scheduling};
pub use log::LevelFilter;
......@@ -213,6 +214,13 @@ where
}
}
/// Immediately kills the current process and all its subprocesses with a message to stderr
pub fn critical(msg: &str) -> ! {
eprintln!("{}", msg.red().bold());
thread_rt::suicide_myself(Duration::from_secs(0), false);
std::process::exit(1);
}
/// Terminates the current process and all its subprocesses in the specified period of time with
/// SIGKILL command. Useful if a process is unable to shut it down gracefully within a specified
/// period of time.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论