File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,19 @@ use crate::{
65
65
io:: Stdio ,
66
66
} ;
67
67
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
+
68
81
pub type ExecProcess = ProcessTemplate < RuncExecLifecycle > ;
69
82
pub type InitProcess = ProcessTemplate < RuncInitLifecycle > ;
70
83
@@ -311,6 +324,15 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
311
324
p. pid
312
325
) ) ;
313
326
}
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
+
314
336
containerd_shim:: cgroup:: update_resources ( p. pid as u32 , resources)
315
337
}
316
338
@@ -327,6 +349,15 @@ impl ProcessLifecycle<InitProcess> for RuncInitLifecycle {
327
349
p. pid
328
350
) ) ;
329
351
}
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
+
330
361
containerd_shim:: cgroup:: collect_metrics ( p. pid as u32 )
331
362
}
332
363
You can’t perform that action at this time.
0 commit comments