mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 21:21:32 +00:00
container: implement exit code xenbus notification
This commit is contained in:
@ -25,8 +25,8 @@ features = ["process"]
|
||||
[dependencies.krata]
|
||||
path = "../shared"
|
||||
|
||||
[dependencies.xenevtchn]
|
||||
path = "../libs/xen/xenevtchn"
|
||||
[dependencies.xenstore]
|
||||
path = "../libs/xen/xenstore"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
@ -4,6 +4,7 @@ use crate::childwait::{ChildEvent, ChildWait};
|
||||
use anyhow::Result;
|
||||
use nix::{libc::c_int, unistd::Pid};
|
||||
use tokio::{select, time::sleep};
|
||||
use xenstore::client::{XsdClient, XsdInterface};
|
||||
|
||||
pub struct ContainerBackground {
|
||||
child: Pid,
|
||||
@ -40,8 +41,11 @@ impl ContainerBackground {
|
||||
}
|
||||
|
||||
async fn death(&mut self, code: c_int) -> Result<()> {
|
||||
println!("[krata] container process exited: status = {}", code);
|
||||
println!("[krata] looping forever");
|
||||
let mut store = XsdClient::open().await?;
|
||||
store
|
||||
.write_string("krata/guest/exit-code", &code.to_string())
|
||||
.await?;
|
||||
drop(store);
|
||||
loop {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
Reference in New Issue
Block a user