|
|
@ -231,7 +231,13 @@ impl Application {
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[cfg(windows)]
|
|
|
|
let signals = futures_util::stream::empty();
|
|
|
|
let signals = futures_util::stream::empty();
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
let signals = Signals::new([signal::SIGTSTP, signal::SIGCONT, signal::SIGUSR1])
|
|
|
|
let signals = Signals::new([
|
|
|
|
|
|
|
|
signal::SIGTSTP,
|
|
|
|
|
|
|
|
signal::SIGCONT,
|
|
|
|
|
|
|
|
signal::SIGUSR1,
|
|
|
|
|
|
|
|
signal::SIGTERM,
|
|
|
|
|
|
|
|
signal::SIGINT,
|
|
|
|
|
|
|
|
])
|
|
|
|
.context("build signal handler")?;
|
|
|
|
.context("build signal handler")?;
|
|
|
|
|
|
|
|
|
|
|
|
let app = Self {
|
|
|
|
let app = Self {
|
|
|
@ -318,7 +324,9 @@ impl Application {
|
|
|
|
biased;
|
|
|
|
biased;
|
|
|
|
|
|
|
|
|
|
|
|
Some(signal) = self.signals.next() => {
|
|
|
|
Some(signal) = self.signals.next() => {
|
|
|
|
self.handle_signals(signal).await;
|
|
|
|
if !self.handle_signals(signal).await {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Some(event) = input_stream.next() => {
|
|
|
|
Some(event) = input_stream.next() => {
|
|
|
|
self.handle_terminal_events(event).await;
|
|
|
|
self.handle_terminal_events(event).await;
|
|
|
@ -442,10 +450,12 @@ impl Application {
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[cfg(windows)]
|
|
|
|
// no signal handling available on windows
|
|
|
|
// no signal handling available on windows
|
|
|
|
pub async fn handle_signals(&mut self, _signal: ()) {}
|
|
|
|
pub async fn handle_signals(&mut self, _signal: ()) -> bool {
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
pub async fn handle_signals(&mut self, signal: i32) {
|
|
|
|
pub async fn handle_signals(&mut self, signal: i32) -> bool {
|
|
|
|
match signal {
|
|
|
|
match signal {
|
|
|
|
signal::SIGTSTP => {
|
|
|
|
signal::SIGTSTP => {
|
|
|
|
self.restore_term().unwrap();
|
|
|
|
self.restore_term().unwrap();
|
|
|
@ -499,8 +509,14 @@ impl Application {
|
|
|
|
self.refresh_config();
|
|
|
|
self.refresh_config();
|
|
|
|
self.render().await;
|
|
|
|
self.render().await;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signal::SIGTERM | signal::SIGINT => {
|
|
|
|
|
|
|
|
self.restore_term().unwrap();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
_ => unreachable!(),
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn handle_idle_timeout(&mut self) {
|
|
|
|
pub async fn handle_idle_timeout(&mut self) {
|
|
|
|