mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-28 14:11:34 +02:00
Handle signalling to sub process on non-unix
This commit is contained in:
parent
92513a4dc3
commit
e577b040b9
@ -12,8 +12,6 @@ use tokio::{
|
||||
};
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
pub use command_group::Signal;
|
||||
|
||||
use crate::{
|
||||
command::Supervisor,
|
||||
error::{CriticalError, RuntimeError},
|
||||
@ -232,10 +230,18 @@ async fn apply_outcome(
|
||||
}
|
||||
|
||||
(Some(p), Outcome::Signal(sig)) => {
|
||||
// TODO: windows
|
||||
#[cfg(unix)]
|
||||
if let Some(sig) = sig.to_nix() {
|
||||
p.signal(sig).await;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
if let SubSignal::Terminate = sig {
|
||||
p.kill().await;
|
||||
}
|
||||
// else: https://github.com/watchexec/watchexec/issues/219
|
||||
}
|
||||
|
||||
(Some(p), Outcome::Wait) => {
|
||||
p.wait().await?;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use command_group::Signal;
|
||||
use crate::signal::process::SubSignal;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
@ -16,7 +16,7 @@ pub enum Outcome {
|
||||
Wait,
|
||||
|
||||
/// Send this signal to the command.
|
||||
Signal(Signal),
|
||||
Signal(SubSignal),
|
||||
|
||||
/// Clear the (terminal) screen.
|
||||
Clear,
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! Signal handling.
|
||||
|
||||
pub mod source;
|
||||
pub mod process;
|
||||
pub mod source;
|
||||
|
@ -151,7 +151,9 @@ impl FromStr for SubSignal {
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(sig) = NixSignal::from_str(&s.to_ascii_uppercase()).or_else(|_| NixSignal::from_str(&format!("SIG{}", s.to_ascii_uppercase()))) {
|
||||
if let Ok(sig) = NixSignal::from_str(&s.to_ascii_uppercase())
|
||||
.or_else(|_| NixSignal::from_str(&format!("SIG{}", s.to_ascii_uppercase())))
|
||||
{
|
||||
return Ok(Self::from_nix(sig));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user