return to 2021 features, and add replace old way to detect error when trying to open fifo file

This commit is contained in:
primardj 2024-04-13 19:19:46 +01:00
parent 92c5f4b3a1
commit f2a9af6168
2 changed files with 10 additions and 15 deletions

View file

@ -1,9 +1,10 @@
[package] [package]
name = "sv" name = "sv"
version = "0.2.0" version = "0.2.0"
edition = "2024" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
tokio = { version = "1.37.0", features = ["full"] } tokio = { version = "1.37.0", features = ["full"] }
libc = "0.2"

View file

@ -1,6 +1,4 @@
use std::io::ErrorKind;
use tokio::net::unix::pipe; use tokio::net::unix::pipe;
use tokio::runtime::Runtime; 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); let sender = pipe::OpenOptions::new().open_sender(path);
match sender { match sender {
Ok(..) => {}, Ok(..) => return true,
Err(e) => match e.kind() { Err(e) if e.raw_os_error() == Some(libc::ENXIO) => {
ErrorKind::NotFound => { println!("fail: {sv}: runsv not running");
println!("warning: {sv}: unable to open {path}: file does not exist"); return false;
return false; },
}, Err(..) => {
_ => { println!("warning: {sv}: unable to open {path}: file does not exist");
println!("fail: {sv}: runsv not running"); return false;
return false;
}
}, },
}; };
return true
} }