diff --git a/Cargo.lock b/Cargo.lock
index 89424ab..7490101 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -117,7 +117,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pino"
-version = "1.1.1"
+version = "1.1.3"
dependencies = [
"argh",
"fltk",
diff --git a/Cargo.toml b/Cargo.toml
index 9c9158e..dc0b9c4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pino"
-version = "1.1.2"
+version = "1.1.3"
edition = "2024"
[dependencies]
diff --git a/src/main.rs b/src/main.rs
index 2dc5782..0a3198f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,13 @@
use argh::FromArgs;
use serde::Deserialize;
use std::{fs, io::Write, os::unix::net::UnixStream, path::Path};
+use utils::is_running;
mod colors;
mod config;
mod screen;
mod ui;
+mod utils;
#[derive(FromArgs)]
#[argh(
@@ -108,7 +110,7 @@ fn main() {
let args: Arg = argh::from_env();
if args.version {
- println!("v1.1.2");
+ println!("v1.1.3");
return;
}
@@ -134,7 +136,7 @@ fn main() {
let config_content = fs::read_to_string(config_file).expect("Faild ");
let config: Config = toml::from_str(&config_content).expect("Faild");
- if Path::new("/tmp/pino-check.sock").exists() {
+ if Path::new("/tmp/pino-check.sock").exists() && is_running() {
let mut stream = UnixStream::connect("/tmp/pino-check.sock").unwrap();
stream
.write_all(
diff --git a/src/ui.rs b/src/ui.rs
index 025ab1d..dfc8167 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -96,8 +96,7 @@ pub fn ui(
});
let (tx, rx) = mpsc::channel::<(String, String, u64)>();
- tx.send((data.0, data.1, data.2))
- .unwrap();
+ tx.send((data.0, data.1, data.2)).unwrap();
let socket_path = "/tmp/pino-check.sock";
if Path::new(socket_path).exists() {
diff --git a/src/utils.rs b/src/utils.rs
new file mode 100644
index 0000000..698a237
--- /dev/null
+++ b/src/utils.rs
@@ -0,0 +1,20 @@
+use std::process::{Command, Stdio};
+
+pub fn is_running() -> bool {
+ let output = Command::new("pgrep")
+ .arg("-x")
+ .arg("pino")
+ .stdout(Stdio::piped())
+ .stderr(Stdio::null())
+ .output();
+
+ match output {
+ Ok(output) if output.status.success() => {
+ let pids = String::from_utf8_lossy(&output.stdout);
+
+ pids.lines().count() == 2
+ }
+
+ _ => false,
+ }
+}