diff --git a/01_phase_rust_src/sv/Cargo.toml b/01_phase_rust_src/sv/Cargo.toml index 43f8a44..ba98c18 100644 --- a/01_phase_rust_src/sv/Cargo.toml +++ b/01_phase_rust_src/sv/Cargo.toml @@ -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" diff --git a/01_phase_rust_src/sv/src/status_obj/misc.rs b/01_phase_rust_src/sv/src/status_obj/misc.rs index 85dbd6c..b01c341 100644 --- a/01_phase_rust_src/sv/src/status_obj/misc.rs +++ b/01_phase_rust_src/sv/src/status_obj/misc.rs @@ -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 => { - println!("warning: {sv}: unable to open {path}: file does not exist"); - return false; - }, - _ => { - println!("fail: {sv}: runsv not running"); - return false; - } + 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; }, }; - - return true }