Support graceful termination via SIGINT (#23)

* Support graceful termination via SIGINT

* $ cargo fmt

* Explain why we need to ignore the SIGINT
This commit is contained in:
Nikolay Edigaryev
2023-03-16 18:38:03 +04:00
committed by GitHub
parent 535e03c97f
commit d7699e95a9
5 changed files with 405 additions and 309 deletions
+6 -1
View File
@@ -43,7 +43,7 @@ impl Proxy {
self.poller.arm()?;
loop {
let (vm_readable, host_readable) = self.poller.wait()?;
let (vm_readable, host_readable, interrupt) = self.poller.wait()?;
if vm_readable {
self.read_from_vm(buf.as_mut_slice())?;
@@ -53,6 +53,11 @@ impl Proxy {
self.read_from_host(buf.as_mut_slice())?;
}
// Graceful termination
if interrupt {
return Ok(());
}
self.poller.rearm()?;
}
}