Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Release v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Dec 30, 2023
1 parent 2a358af commit 301c60c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
14 changes: 1 addition & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "atomicalsir"
readme = "README.md"
repository = "https://github.com/hack-ink/atomicalsir"
version = "0.1.2"
version = "0.1.3"

[profile.ci-dev]
incremental = false
Expand All @@ -27,7 +27,6 @@ vergen = { version = "8.2", features = ["build", "cargo", "git", "gitcl"] }
anyhow = { version = "1.0" }
clap = { version = "4.4", features = ["color", "derive"] }
color-eyre = { version = "0.6" }
nix = { version = "0.27", features = ["signal"] }
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
Expand Down
22 changes: 15 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ use clap::{
},
Parser, ValueEnum,
};
use nix::{
sys::signal::{self, Signal},
unistd::Pid,
};
use serde::Deserialize;

#[tokio::main]
Expand Down Expand Up @@ -284,7 +280,7 @@ fn execute(
}

let mut child = cmd.spawn()?;
let id = child.id();
let pid = child.id();
let should_terminate = Arc::new(AtomicBool::new(false));
let stdout_st = should_terminate.clone();
let stdout_r = BufReader::new(child.stdout.take().unwrap());
Expand Down Expand Up @@ -312,7 +308,7 @@ fn execute(
_ => (),
}

signal::kill(Pid::from_raw(id as i32), Signal::SIGKILL)?;
kill(pid)?;

break;
}
Expand All @@ -336,7 +332,8 @@ fn execute(

if l.contains("worker stopped with exit code 1") {
tracing::warn!("worker stopped with exit code 1; killing process");
signal::kill(Pid::from_raw(id as i32), Signal::SIGKILL)?;

kill(pid)?;

break;
}
Expand All @@ -355,3 +352,14 @@ fn execute(

Ok(())
}

fn kill(pid: u32) -> Result<()> {
let pid = pid.to_string();

#[cfg(any(target_os = "linux", target_os = "macos"))]
Command::new("kill").args(["-9", &pid]).output()?;
#[cfg(target_os = "windows")]
Command::new("taskkill").args(["/F", "/PID", &pid]).output()?;

Ok(())
}

0 comments on commit 301c60c

Please sign in to comment.