Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn init_stage_parent(args: SetupArgs) -> isize {
0 // Exit child process
}

fn init_stage_child(args: SetupArgs) -> ! {
fn init_stage_child(args: SetupArgs) -> isize {
let linux_spec = args.config.spec.linux().as_ref().unwrap();
debug!("Enter init_stage child");
let _ = prctl::set_name("runh:INIT");
Expand Down Expand Up @@ -611,6 +611,7 @@ fn init_stage_child(args: SetupArgs) -> ! {
nix::unistd::close(fifo_fd).expect("Could not close exec fifo O_PATH fd!");
nix::unistd::close(init_pipe.into_raw_fd()).expect("Could not close init pipe fd!");

let mut child = None;
if args.config.is_hermit_container {
let micro_vm: u32 = env::var("RUNH_MICRO_VM")
.unwrap_or_else(|_| "0".to_string())
Expand Down Expand Up @@ -650,7 +651,7 @@ fn init_stage_child(args: SetupArgs) -> ! {
}
cmd.envs(std::env::vars());

let _child = cmd.spawn().expect("Unable to virtiofsd");
child = Some(cmd.spawn().expect("Unable to virtiofsd"));
}
}

Expand All @@ -664,8 +665,12 @@ fn init_stage_child(args: SetupArgs) -> ! {
if let Some(tap_fd) = tap_fd {
cmd.preserved_fds(vec![tap_fd]);
}
let error = cmd.exec();
let status = cmd.status().unwrap();
assert!(status.success());

//This point should not be reached on successful exec
panic!("exec failed with error {}", error)
if let Some(mut child) = child {
child.wait().unwrap();
}

0
}