diff options
author | Christian Duerr <contact@christianduerr.com> | 2020-08-06 00:42:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 00:42:49 +0000 |
commit | 291de2500f0cbd189a9b017809091b6eb8f8f0ec (patch) | |
tree | a1a5005e33bbc47bf8801066f7214868fb53e971 /alacritty_terminal/src/tty | |
parent | 99c34c7ce92fe02c733b5fd19dd054783038f037 (diff) | |
download | alacritty-291de2500f0cbd189a9b017809091b6eb8f8f0ec.tar.gz alacritty-291de2500f0cbd189a9b017809091b6eb8f8f0ec.zip |
Use `tcgetpgrp` to get PID for SpawnNewInstance
Fixes #4082.
Diffstat (limited to 'alacritty_terminal/src/tty')
-rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 3998d9e6..c52da34d 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -13,7 +13,7 @@ use std::os::unix::{ }; use std::process::{Child, Command, Stdio}; use std::ptr; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicI32, AtomicUsize, Ordering}; use libc::{self, c_int, pid_t, winsize, TIOCSCTTY}; use log::error; @@ -33,6 +33,9 @@ use crate::tty::{ChildEvent, EventedPty, EventedReadWrite}; /// Necessary to put this in static storage for `SIGCHLD` to have access. static PID: AtomicUsize = AtomicUsize::new(0); +/// File descriptor of terminal master. +static FD: AtomicI32 = AtomicI32::new(-1); + macro_rules! die { ($($arg:tt)*) => {{ error!($($arg)*); @@ -44,6 +47,10 @@ pub fn child_pid() -> pid_t { PID.load(Ordering::Relaxed) as pid_t } +pub fn master_fd() -> RawFd { + FD.load(Ordering::Relaxed) as RawFd +} + /// Get raw fds for master/slave ends of a new PTY. fn make_pty(size: winsize) -> (RawFd, RawFd) { let mut win_size = size; @@ -224,8 +231,9 @@ pub fn new<C>(config: &Config<C>, size: &SizeInfo, window_id: Option<usize>) -> match builder.spawn() { Ok(child) => { - // Remember child PID so other modules can use it. + // Remember master FD and child PID so other modules can use it. PID.store(child.id() as usize, Ordering::Relaxed); + FD.store(master, Ordering::Relaxed); unsafe { // Maybe this should be done outside of this function so nonblocking |