tony / oxwm

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