Skip to content

Commit 4e92198

Browse files
authored
Fix the tty_path test on FreeBSD (#334)
On FreeBSD, ttyname(3) may not return exactly the same name as was used to open the file descriptor. For example, "/dev/tty" is an alias for whatever the real tty device is. But paths like "/dev/pts/0" aren't aliases. If the user can open them, ttyname() will always return their own name. Note that the test will still fail on non-Linux, non-Darwin due to an unrelated Rustix bug. See bytecodealliance/rustix#832
1 parent 5e9248c commit 4e92198

File tree

1 file changed

+3
-2
lines changed
  • cap-primitives/src/rustix/fs

1 file changed

+3
-2
lines changed

cap-primitives/src/rustix/fs/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ fn tty_path() {
121121
#[cfg(unix)]
122122
use std::os::unix::fs::FileTypeExt;
123123

124-
// On FreeBSD, `ttyname` doesn't seem to work on /dev/std{in,out,err}.
124+
// On FreeBSD, /dev/{tty,stdin,stdout,stderr} are aliases to different real
125+
// devices.
125126
let paths: &[&str] = if cfg!(target_os = "freebsd") {
126-
&["/dev/tty"]
127+
&["/dev/ttyv0", "/dev/pts/0"]
127128
} else {
128129
&["/dev/tty", "/dev/stdin", "/dev/stdout", "/dev/stderr"]
129130
};

0 commit comments

Comments
 (0)