Fixed zombie processes
Browse files
+1 −0 Cargo.lock
| @@ -295,6 +295,7 @@ version = "0.8.1" | ||
| 295 | 295 | dependencies = [ |
| 296 | 296 | "chrono", |
| 297 | 297 | "dirs", |
| 298 | + "libc", | |
| 298 | 299 | "mlua", |
| 299 | 300 | "serde", |
| 300 | 301 | "x11", |
+1 −0 Cargo.toml
| @@ -18,3 +18,4 @@ chrono = "0.4" | ||
| 18 | 18 | dirs = "5.0" |
| 19 | 19 | serde = { version = "1.0", features = ["derive"] } |
| 20 | 20 | mlua = { version = "0.10", features = ["lua54", "vendored"] } |
| 21 | +libc = "0.2" |
+2 −0 src/bin/main.rs
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | 3 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 4 | + oxwm::signal::prevent_zombie_processes(); | |
| 5 | + | |
| 4 | 6 | let arguments: Vec<String> = std::env::args().collect(); |
| 5 | 7 | |
| 6 | 8 | let mut custom_config_path: Option<PathBuf> = None; |
+1 −0 src/lib.rs
| @@ -6,6 +6,7 @@ pub mod keyboard; | ||
| 6 | 6 | pub mod layout; |
| 7 | 7 | pub mod monitor; |
| 8 | 8 | pub mod overlay; |
| 9 | +pub mod signal; | |
| 9 | 10 | pub mod size_hints; |
| 10 | 11 | pub mod tab_bar; |
| 11 | 12 | pub mod window_manager; |
+13 −0 src/signal.rs new file mode 100644
| @@ -0,0 +1,13 @@ | ||
| 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 | +} |