mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-25 22:20:53 +03:00
unix: send SIGTERM instead of killing the service (#59)
This commit is contained in:
committed by
GitHub
parent
4b6faea93a
commit
e155819542
@@ -25,7 +25,7 @@ pub fn run() -> Result<()> {
|
||||
loop {
|
||||
let mut buf = String::new();
|
||||
match std::io::stdin().read_line(&mut buf) {
|
||||
Ok(0) => break,
|
||||
Ok(0) => return,
|
||||
Ok(len) => {
|
||||
if let Some(events) = parse_cmd(buf, len) {
|
||||
for event in events.iter() {
|
||||
@@ -48,14 +48,16 @@ pub fn run() -> Result<()> {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("error reading from stdin: {e}");
|
||||
break;
|
||||
if e.kind() != ErrorKind::UnexpectedEof {
|
||||
log::error!("error reading from stdin: {e}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
let writer = thread::Builder::new()
|
||||
let _ = thread::Builder::new()
|
||||
.name("cli-frontend-notify".to_string())
|
||||
.spawn(move || {
|
||||
loop {
|
||||
@@ -124,7 +126,7 @@ pub fn run() -> Result<()> {
|
||||
}
|
||||
})?;
|
||||
match reader.join() {
|
||||
Ok(_) => (),
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
let msg = match (e.downcast_ref::<&str>(), e.downcast_ref::<String>()) {
|
||||
(Some(&s), _) => s,
|
||||
@@ -134,17 +136,6 @@ pub fn run() -> Result<()> {
|
||||
log::error!("reader thread paniced: {msg}");
|
||||
}
|
||||
}
|
||||
match writer.join() {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
let msg = match (e.downcast_ref::<&str>(), e.downcast_ref::<String>()) {
|
||||
(Some(&s), _) => s,
|
||||
(_, Some(s)) => s,
|
||||
_ => "no panic info",
|
||||
};
|
||||
log::error!("writer thread paniced: {msg}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user