From af88ff847d44adec5d17e7cf7dc35f57655ed6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Wed, 11 Dec 2024 13:58:57 +0100 Subject: [PATCH 1/2] fix(init): spawn child instead of becoming one --- src/init.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/init.rs b/src/init.rs index cdf7ec9a..5f0e8b43 100644 --- a/src/init.rs +++ b/src/init.rs @@ -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"); @@ -664,8 +664,8 @@ 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) + 0 } From efabe9b9d29f027848a8a84ee4514560fd748359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= <martin.kroening@eonerc.rwth-aachen.de> Date: Wed, 11 Dec 2024 14:00:46 +0100 Subject: [PATCH 2/2] fix(init): `clippy::zombie_processes` --- src/init.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.rs b/src/init.rs index 5f0e8b43..50635127 100644 --- a/src/init.rs +++ b/src/init.rs @@ -611,6 +611,7 @@ fn init_stage_child(args: SetupArgs) -> isize { 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()) @@ -650,7 +651,7 @@ fn init_stage_child(args: SetupArgs) -> isize { } cmd.envs(std::env::vars()); - let _child = cmd.spawn().expect("Unable to virtiofsd"); + child = Some(cmd.spawn().expect("Unable to virtiofsd")); } } @@ -667,5 +668,9 @@ fn init_stage_child(args: SetupArgs) -> isize { let status = cmd.status().unwrap(); assert!(status.success()); + if let Some(mut child) = child { + child.wait().unwrap(); + } + 0 }