Fix compilation error on Windows
This commit is contained in:
parent
0d2a6fe95d
commit
e98daedd6b
|
@ -160,6 +160,7 @@ extern "C" fn keypress_callback(
|
||||||
// Send the char through the channel
|
// Send the char through the channel
|
||||||
match string {
|
match string {
|
||||||
Ok(string) => {
|
Ok(string) => {
|
||||||
|
println!("{}", string);
|
||||||
let event = Event::Key(KeyEvent::Char(string));
|
let event = Event::Key(KeyEvent::Char(string));
|
||||||
(*_self).send_channel.send(event).unwrap();
|
(*_self).send_channel.send(event).unwrap();
|
||||||
}
|
}
|
||||||
|
|
55
src/main.rs
55
src/main.rs
|
@ -407,31 +407,7 @@ fn daemon_main(config_set: ConfigSet) {
|
||||||
})
|
})
|
||||||
.expect("Unable to spawn worker monitor thread");
|
.expect("Unable to spawn worker monitor thread");
|
||||||
|
|
||||||
if !cfg!(target_os = "windows") {
|
register_signals(config_set.default.clone());
|
||||||
// On Unix, also listen for signals so that we can terminate the
|
|
||||||
// worker if the daemon receives a signal
|
|
||||||
use signal_hook::{iterator::Signals, SIGTERM, SIGINT};
|
|
||||||
let signals = Signals::new(&[SIGTERM, SIGINT]).expect("unable to register for signals");
|
|
||||||
let config_set = config_set.clone();
|
|
||||||
thread::Builder::new()
|
|
||||||
.name("signal monitor".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
for signal in signals.forever() {
|
|
||||||
info!("Received signal: {:?}, terminating worker", signal);
|
|
||||||
send_command_or_warn(
|
|
||||||
Service::Worker,
|
|
||||||
config_set.default.clone(),
|
|
||||||
IPCCommand::exit_worker(),
|
|
||||||
);
|
|
||||||
|
|
||||||
std::thread::sleep(Duration::from_millis(200));
|
|
||||||
|
|
||||||
info!("terminating espanso.");
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.expect("Unable to spawn worker monitor thread");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::thread::sleep(Duration::from_millis(200));
|
std::thread::sleep(Duration::from_millis(200));
|
||||||
|
|
||||||
|
@ -497,6 +473,35 @@ fn daemon_main(config_set: ConfigSet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn register_signals(_: Configs) {}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
fn register_signals(config: Configs) {
|
||||||
|
// On Unix, also listen for signals so that we can terminate the
|
||||||
|
// worker if the daemon receives a signal
|
||||||
|
use signal_hook::{iterator::Signals, SIGTERM, SIGINT};
|
||||||
|
let signals = Signals::new(&[SIGTERM, SIGINT]).expect("unable to register for signals");
|
||||||
|
thread::Builder::new()
|
||||||
|
.name("signal monitor".to_string())
|
||||||
|
.spawn(move || {
|
||||||
|
for signal in signals.forever() {
|
||||||
|
info!("Received signal: {:?}, terminating worker", signal);
|
||||||
|
send_command_or_warn(
|
||||||
|
Service::Worker,
|
||||||
|
config,
|
||||||
|
IPCCommand::exit_worker(),
|
||||||
|
);
|
||||||
|
|
||||||
|
std::thread::sleep(Duration::from_millis(200));
|
||||||
|
|
||||||
|
info!("terminating espanso.");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.expect("Unable to spawn signal monitor thread");
|
||||||
|
}
|
||||||
|
|
||||||
fn watcher_background(sender: Sender<Event>) {
|
fn watcher_background(sender: Sender<Event>) {
|
||||||
// Create a channel to receive the events.
|
// Create a channel to receive the events.
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user