diff options
author | Jakob Hellermann <jakob.hellermann@protonmail.com> | 2024-05-23 16:03:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 18:03:28 +0400 |
commit | e9d4ac2a6ba5347998bd5d9eff1656b0c82e22e3 (patch) | |
tree | cfd6dca9c36f50ee7de26c3811b3aeca11a4ae4a | |
parent | f04b16161bc542075fdb8e5946a8eed976f26b0b (diff) | |
download | alacritty-e9d4ac2a6ba5347998bd5d9eff1656b0c82e22e3.tar.gz alacritty-e9d4ac2a6ba5347998bd5d9eff1656b0c82e22e3.zip |
Fix IO safety violation from consequent dropping `OwnedFd`
This was not a _real_ violation and was _expected_, though for rust
to not complain clone FD properly...
-rw-r--r-- | alacritty_terminal/src/tty/unix.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 1a2104c6..8f335500 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -5,10 +5,10 @@ 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::io::AsRawFd; use std::os::unix::net::UnixStream; use std::os::unix::process::CommandExt; -use std::process::{Child, Command, Stdio}; +use std::process::{Child, Command}; use std::sync::Arc; use std::{env, ptr}; @@ -212,12 +212,9 @@ pub fn from_fd(config: &Options, window_id: u64, master: OwnedFd, slave: OwnedFd }; // Setup child stdin/stdout/stderr as slave fd of PTY. - // Ownership of fd is transferred to the Stdio structs and will be closed by them at the end of - // this scope. (It is not an issue that the fd is closed three times since File::drop ignores - // error on libc::close.). - builder.stdin(unsafe { Stdio::from_raw_fd(slave_fd) }); - builder.stderr(unsafe { Stdio::from_raw_fd(slave_fd) }); - builder.stdout(unsafe { Stdio::from_raw_fd(slave_fd) }); + builder.stdin(slave.try_clone()?); + builder.stderr(slave.try_clone()?); + builder.stdout(slave); // Setup shell environment. let window_id = window_id.to_string(); |