diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 25 |
1 files changed, 22 insertions, 3 deletions
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)) {} + }; } |