| 1 | use std::ptr; |
| 2 | |
| 3 | pub fn prevent_zombie_processes() { |
| 4 | unsafe { |
| 5 | let mut sa: libc::sigaction = std::mem::zeroed(); |
| 6 | libc::sigemptyset(&mut sa.sa_mask); |
| 7 | sa.sa_flags = libc::SA_NOCLDSTOP | libc::SA_NOCLDWAIT | libc::SA_RESTART; |
| 8 | sa.sa_sigaction = libc::SIG_IGN; |
| 9 | libc::sigaction(libc::SIGCHLD, &sa, ptr::null_mut()); |
| 10 | |
| 11 | while libc::waitpid(-1, ptr::null_mut(), libc::WNOHANG) > 0 {} |
| 12 | } |
| 13 | } |