@@ -397,12 +397,8 @@ fn prepare_pty_namespace_and_reopen_fds() -> Result<()> {
397397// PID namespace
398398//////////////////////////////////
399399
400- fn monitor_container ( container_pid : Pid ) -> ! {
401- let result = monitor_child ( container_pid) ;
402-
403- cleanup_current_container ( ) ;
404-
405- if let Err ( e) = result {
400+ fn container_monitor_exit_process ( monitor_child_result : Result < ( ) > ) -> ! {
401+ if let Err ( e) = monitor_child_result {
406402 // Our child logs errors when exiting, so we skip logging in this case
407403 match e. downcast_ref :: < ChildDied > ( ) {
408404 Some ( ChildDied :: Exited ( _) ) => { } ,
@@ -432,7 +428,9 @@ fn prepare_pid_namespace() -> Result<()> {
432428 write_container_pid_file ( container_pid)
433429 . map_err ( |e| { let _ = kill ( container_pid, signal:: SIGKILL ) ; e } ) ?;
434430
435- monitor_container ( container_pid) ;
431+ let result = monitor_child ( container_pid) ;
432+ cleanup_current_container ( ) ;
433+ container_monitor_exit_process ( result) ;
436434 // unreachable
437435 }
438436
@@ -555,7 +553,8 @@ fn nsenter(name: &str) -> Result<()> {
555553 raise_all_effective_caps_to_ambient ( ) ?;
556554
557555 if let ForkResult :: Parent { child : pid } = fork ( ) ? {
558- monitor_container ( pid) ;
556+ let result = monitor_child ( pid) ;
557+ container_monitor_exit_process ( result) ;
559558 // unreachable
560559 }
561560
0 commit comments