Diff
diff --git a/Cargo.lock b/Cargo.lock
index 2566f7f..6b613df 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -295,6 +295,7 @@ version = "0.8.1"
dependencies = [
"chrono",
"dirs",
+ "libc",
"mlua",
"serde",
"x11",
diff --git a/Cargo.toml b/Cargo.toml
index 6a13c55..fb1078a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,3 +18,4 @@ chrono = "0.4"
dirs = "5.0"
serde = { version = "1.0", features = ["derive"] }
mlua = { version = "0.10", features = ["lua54", "vendored"] }
+libc = "0.2"
diff --git a/src/bin/main.rs b/src/bin/main.rs
index f6de012..9eb3692 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -1,6 +1,8 @@
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
+ oxwm::signal::prevent_zombie_processes();
+
let arguments: Vec<String> = std::env::args().collect();
let mut custom_config_path: Option<PathBuf> = None;
diff --git a/src/lib.rs b/src/lib.rs
index 77b8c60..29c68c9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,7 @@ pub mod keyboard;
pub mod layout;
pub mod monitor;
pub mod overlay;
+pub mod signal;
pub mod size_hints;
pub mod tab_bar;
pub mod window_manager;
diff --git a/src/signal.rs b/src/signal.rs
new file mode 100644
index 0000000..408fbd8
--- /dev/null
+++ b/src/signal.rs
@@ -0,0 +1,13 @@
+use std::ptr;
+
+pub fn prevent_zombie_processes() {
+ unsafe {
+ let mut sa: libc::sigaction = std::mem::zeroed();
+ libc::sigemptyset(&mut sa.sa_mask);
+ sa.sa_flags = libc::SA_NOCLDSTOP | libc::SA_NOCLDWAIT | libc::SA_RESTART;
+ sa.sa_sigaction = libc::SIG_IGN;
+ libc::sigaction(libc::SIGCHLD, &sa, ptr::null_mut());
+
+ while libc::waitpid(-1, ptr::null_mut(), libc::WNOHANG) > 0 {}
+ }
+}