Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys::termios: adding ControlFlags::ECHO #2420

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions test/test_pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ fn open_ptty_pair() -> (PtyMaster, File) {
let _m = crate::PTSNAME_MTX.lock();

// Open a new PTTY master
let master = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed");
let master = posix_openpt(OFlag::O_RDWR | OFlag::O_NOCTTY)
.expect("posix_openpt failed");

// Allow a slave to be generated for it
grantpt(&master).expect("grantpt failed");
Expand All @@ -94,9 +95,12 @@ fn open_ptty_pair() -> (PtyMaster, File) {
let slave_name = unsafe { ptsname(&master) }.expect("ptsname failed");

// Open the slave device
let slave_fd =
open(Path::new(&slave_name), OFlag::O_RDWR, stat::Mode::empty())
.unwrap();
let slave_fd = open(
Path::new(&slave_name),
OFlag::O_RDWR | OFlag::O_NOCTTY,
stat::Mode::empty(),
)
.unwrap();

#[cfg(solarish)]
// TODO: rewrite using ioctl!
Expand All @@ -123,6 +127,16 @@ fn open_ptty_pair() -> (PtyMaster, File) {

let slave = unsafe { File::from_raw_fd(slave_fd) };

#[cfg(solarish)]
{
let mut tty = tcgetattr(&slave).expect("tcgetattr failed");
tty.local_flags &= !(LocalFlags::ICANON | LocalFlags::ECHO);
tty.control_chars[SpecialCharacterIndices::VMIN as usize] = 1;
tty.control_chars[SpecialCharacterIndices::VTIME as usize] = 0;

tcsetattr(&slave, SetArg::TCSANOW, &tty).expect("tcsetattr failed");
}

(master, slave)
}

Expand Down