summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock33
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs25
3 files changed, 55 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 0bb8497..34714c9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9,14 +9,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
+name = "bitflags"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
+
+[[package]]
name = "blow"
version = "0.1.0"
dependencies = [
+ "nix",
"xcb",
"xkeysym",
]
[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
+[[package]]
name = "libc"
version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -29,6 +48,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
+name = "nix"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
+dependencies = [
+ "bitflags 2.5.0",
+ "cfg-if",
+ "cfg_aliases",
+ "libc",
+]
+
+[[package]]
name = "quick-xml"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -43,7 +74,7 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e75181b5a62b6eeaa72f303d3cef7dbb841e22885bf6d3e66fe23e88c55dc6"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
"libc",
"quick-xml",
]
diff --git a/Cargo.toml b/Cargo.toml
index e0ebbcb..0bfdea5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
+nix = { version = "0.29.0", features = ["signal"] }
xcb = { version = "1.4.0", features = ["xinerama"] }
xkeysym = "0.2.0"
diff --git a/src/main.rs b/src/main.rs
index 09ef1f2..a5091ad 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -21,6 +21,13 @@
use clients::ClientState;
use conn_info::Connection;
pub use error::*;
+use nix::{
+ sys::{
+ signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal},
+ wait::{waitpid, WaitPidFlag},
+ },
+ unistd::Pid,
+};
use xcb::{
x::{self, PropertyNotifyEvent},
Connection as RawConnection, Event, Extension,
@@ -117,7 +124,19 @@ impl<'a> WM<'a> {
/// Cleanup this process' children and set some flags.
/// This is necessary when used with `startx`.
fn cleanup_process_children() {
- // TODO: dont transform children into zombies when they terminate
- // TODO: cleanup zombies
- // todo!()
+ unsafe {
+ // Don't transform children into zombies when they terminate
+ sigaction(
+ Signal::SIGCHLD,
+ &SigAction::new(
+ SigHandler::SigIgn,
+ SaFlags::SA_NOCLDSTOP | SaFlags::SA_NOCLDWAIT | SaFlags::SA_RESTART,
+ SigSet::empty(),
+ ),
+ )
+ .unwrap();
+
+ // Immediately wait for zombie processes to die - sometimes these come from startx.
+ while let Ok(_) = waitpid(Pid::from_raw(-1), Some(WaitPidFlag::WNOHANG)) {}
+ };
}