zombie/lib.rs
1extern crate libc;
2
3use libc::pid_t;
4use libc::c_int;
5
6const WNOHANG : c_int = 0x00000001;
7
8extern {
9 pub fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t;
10}
11
12pub fn collect_zombies() {
13 unsafe {
14 while waitpid(-1, std::ptr::null_mut(), WNOHANG) > 0 {
15 }
16 }
17}