File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,19 @@ use crate::{
6565 io:: Stdio ,
6666} ;
6767
68+ /// check the process is zombie
69+ #[ cfg( target_os = "linux" ) ]
70+ fn is_zombie_process ( pid : i32 ) -> bool {
71+ if let Ok ( status) = std:: fs:: read_to_string ( format ! ( "/proc/{}/status" , pid) ) {
72+ for line in status. lines ( ) {
73+ if line. starts_with ( "State:" ) && line. contains ( 'Z' ) {
74+ return true ;
75+ }
76+ }
77+ }
78+ false
79+ }
80+
6881pub type ExecProcess = ProcessTemplate < RuncExecLifecycle > ;
6982pub type InitProcess = ProcessTemplate < RuncInitLifecycle > ;
7083
@@ -311,6 +324,15 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
311324 p. pid
312325 ) ) ;
313326 }
327+
328+ // check the process is zombie
329+ if is_zombie_process ( p. pid ) {
330+ return Err ( other ! (
331+ "failed to update resources because process {} is a zombie" ,
332+ p. pid
333+ ) ) ;
334+ }
335+
314336 containerd_shim:: cgroup:: update_resources ( p. pid as u32 , resources)
315337 }
316338
@@ -327,6 +349,15 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
327349 p. pid
328350 ) ) ;
329351 }
352+
353+ // check the process is zombie
354+ if is_zombie_process ( p. pid ) {
355+ return Err ( other ! (
356+ "failed to collect metrics because process {} is a zombie" ,
357+ p. pid
358+ ) ) ;
359+ }
360+
330361 containerd_shim:: cgroup:: collect_metrics ( p. pid as u32 )
331362 }
332363
You can’t perform that action at this time.
0 commit comments