1
0
Fork 0
forked from wry/wry

autocommit 2022-01-06 19:08:32 CET

This commit is contained in:
Julian Orth 2022-01-06 19:08:32 +01:00
parent cbbc41a463
commit 4a939477a2
51 changed files with 3438 additions and 207 deletions

View file

@ -22,6 +22,7 @@ pub enum SighandError {
pub fn install(el: &Rc<EventLoop>) -> Result<(), SighandError> {
let mut set: c::sigset_t = uapi::pod_zeroed();
uapi::sigaddset(&mut set, c::SIGINT).unwrap();
uapi::sigaddset(&mut set, c::SIGTERM).unwrap();
if let Err(e) = uapi::pthread_sigmask(c::SIG_BLOCK, Some(&set), None) {
return Err(SighandError::BlockFailed(e.into()));
}
@ -46,7 +47,7 @@ struct Sighand {
}
impl EventLoopDispatcher for Sighand {
fn dispatch(&self, events: i32) -> Result<(), Box<dyn Error + Send + Sync>> {
fn dispatch(self: Rc<Self>, events: i32) -> Result<(), Box<dyn Error + Send + Sync>> {
if events & (c::EPOLLERR | c::EPOLLHUP) != 0 {
return Err(Box::new(SighandError::ErrorEvent));
}
@ -59,10 +60,8 @@ impl EventLoopDispatcher for Sighand {
}
}
log::info!("Received signal {}", sigfd.ssi_signo);
if sigfd.ssi_signo == c::SIGINT as _ {
log::info!("Exiting");
self.el.stop();
}
log::info!("Exiting");
self.el.stop();
}
Ok(())
}