aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Hellermann <jakob.hellermann@protonmail.com>2024-05-23 16:03:28 +0200
committerJosh Rahm <rahm@google.com>2024-08-14 15:42:41 -0600
commita45adac92c447649a1123557e72939cf43233c99 (patch)
tree172f532c43774a9492e6169d828a706b45306294
parent5691e1ed0ac4f465a9c845b93162e7bb389415b4 (diff)
downloadr-alacritty-a45adac92c447649a1123557e72939cf43233c99.tar.gz
r-alacritty-a45adac92c447649a1123557e72939cf43233c99.tar.bz2
r-alacritty-a45adac92c447649a1123557e72939cf43233c99.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.rs13
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();