more: replace nix::unistd with std::fs (#12268)

This commit is contained in:
xtqqczze
2026-05-13 07:44:26 +02:00
committed by GitHub
parent eca185b22b
commit f4a0bb3bcd
2 changed files with 23 additions and 22 deletions
+5 -5
View File
@@ -2941,12 +2941,12 @@ pub fn whoami() -> String {
/// Create a PTY (pseudo-terminal) for testing utilities that require a TTY.
///
/// Returns a tuple of (path, controller_fd, replica_fd) where:
/// Returns a tuple of (path, controller, replica) where:
/// - path: The filesystem path to the PTY replica device
/// - controller_fd: The controller file descriptor
/// - replica_fd: The replica file descriptor
/// - controller: The controller file
/// - replica: The replica file
#[cfg(unix)]
pub fn pty_path() -> (String, OwnedFd, OwnedFd) {
pub fn pty_path() -> (String, File, File) {
use nix::pty::openpty;
use nix::unistd::ttyname;
let pty = openpty(None, None).expect("Failed to create PTY");
@@ -2954,7 +2954,7 @@ pub fn pty_path() -> (String, OwnedFd, OwnedFd) {
.expect("Failed to get PTY path")
.to_string_lossy()
.to_string();
(path, pty.master, pty.slave)
(path, pty.master.into(), pty.slave.into())
}
/// Add prefix 'g' for `util_name` if not on linux