aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty/unix.rs
diff options
context:
space:
mode:
authorOwen Law <81528246+someone13574@users.noreply.github.com>2024-05-01 01:27:54 -0400
committerJosh Rahm <rahm@google.com>2024-08-14 15:42:41 -0600
commit0e7a84d15fb2674660abca28b9cbc1e6ab0163fe (patch)
tree7990185779d6ea6852678dad09a123b219e6979c /alacritty_terminal/src/tty/unix.rs
parentc9a360155c65a0e22a88d4d1db347d487f6712da (diff)
downloadr-alacritty-0e7a84d15fb2674660abca28b9cbc1e6ab0163fe.tar.gz
r-alacritty-0e7a84d15fb2674660abca28b9cbc1e6ab0163fe.tar.bz2
r-alacritty-0e7a84d15fb2674660abca28b9cbc1e6ab0163fe.zip
Add `from_file_descriptors()` to `tty::unix`
Diffstat (limited to 'alacritty_terminal/src/tty/unix.rs')
-rw-r--r--alacritty_terminal/src/tty/unix.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index a4b07b74..54118a58 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -4,6 +4,7 @@ use std::ffi::CStr;
use std::fs::File;
use std::io::{Error, ErrorKind, Read, Result};
use std::mem::MaybeUninit;
+use std::os::fd::OwnedFd;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::os::unix::net::UnixStream;
use std::os::unix::process::CommandExt;
@@ -184,6 +185,11 @@ fn default_shell_command(shell: &str, user: &str) -> Command {
pub fn new(config: &Options, window_size: WindowSize, window_id: u64) -> Result<Pty> {
let pty = openpty(None, Some(&window_size.to_winsize()))?;
let (master, slave) = (pty.controller, pty.user);
+ from_fd(config, window_id, master, slave)
+}
+
+/// Create a new TTY from a PTY's file descriptors.
+pub fn from_fd(config: &Options, window_id: u64, master: OwnedFd, slave: OwnedFd) -> Result<Pty> {
let master_fd = master.as_raw_fd();
let slave_fd = slave.as_raw_fd();