diff options
author | Joe Wilm <jwilm@users.noreply.github.com> | 2017-12-29 09:19:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-29 09:19:14 -0800 |
commit | 8ce553f28a2ae0d022a774e8341e66dca4079b63 (patch) | |
tree | 1e1d127f9d6f8e1e66215c8f827e5586838b9891 | |
parent | 2879830f1d9245da1bf6947f9738d1b1c85380ee (diff) | |
download | alacritty-8ce553f28a2ae0d022a774e8341e66dca4079b63.tar.gz alacritty-8ce553f28a2ae0d022a774e8341e66dca4079b63.zip |
Fix zombie children (#976)
Resolves #973
-rw-r--r-- | src/input.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs index 1090f12d..6c113ab4 100644 --- a/src/input.rs +++ b/src/input.rs @@ -22,6 +22,7 @@ use std::borrow::Cow; use std::mem; use std::process::Command; use std::time::Instant; +use std::os::unix::process::CommandExt; use copypasta::{Clipboard, Load, Buffer}; use glutin::{ElementState, VirtualKeyCode, MouseButton, TouchPhase, MouseScrollDelta}; @@ -200,7 +201,16 @@ impl Action { }, Action::Command(ref program, ref args) => { trace!("running command: {} {:?}", program, args); - match Command::new(program).args(args).spawn() { + match Command::new(program) + .args(args) + .before_exec(|| { + // Detach forked process from Alacritty. This will cause + // init or whatever to clean up child processes for us. + unsafe { ::libc::daemon(1, 0); } + Ok(()) + }) + .spawn() + { Ok(child) => { debug!("spawned new proc with pid: {}", child.id()); }, |