tony / oxwm

Branch: d5f7b65
Switch branches/tags
master
tonybtw Fixed zombie processes d5f7b65 2025-12-12
13 lines · 431 B Raw Blame History
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 }