return to 2021 features, and add replace old way to detect error when trying to open fifo file
This commit is contained in:
parent
92c5f4b3a1
commit
f2a9af6168
2 changed files with 10 additions and 15 deletions
|
@ -1,9 +1,10 @@
|
|||
[package]
|
||||
name = "sv"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.37.0", features = ["full"] }
|
||||
libc = "0.2"
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
use std::io::ErrorKind;
|
||||
|
||||
use tokio::net::unix::pipe;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
|
@ -85,18 +83,14 @@ pub fn check_fifo(sv: String, path: &str) -> bool {
|
|||
|
||||
let sender = pipe::OpenOptions::new().open_sender(path);
|
||||
match sender {
|
||||
Ok(..) => {},
|
||||
Err(e) => match e.kind() {
|
||||
ErrorKind::NotFound => {
|
||||
Ok(..) => return true,
|
||||
Err(e) if e.raw_os_error() == Some(libc::ENXIO) => {
|
||||
println!("fail: {sv}: runsv not running");
|
||||
return false;
|
||||
},
|
||||
Err(..) => {
|
||||
println!("warning: {sv}: unable to open {path}: file does not exist");
|
||||
return false;
|
||||
},
|
||||
_ => {
|
||||
println!("fail: {sv}: runsv not running");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue