Skip to content

Commit

Permalink
stty: Add documentation with respect to -F.
Browse files Browse the repository at this point in the history
  • Loading branch information
VorpalBlade committed Feb 21, 2023
1 parent 1089fa6 commit 3df6fcb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/uu/stty/src/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ impl<'a> Options<'a> {
all: matches.get_flag(options::ALL),
save: matches.get_flag(options::SAVE),
file: match matches.get_one::<String>(options::FILE) {
// Two notes here:
// 1. O_NONBLOCK is needed because according to GNU docs, a
// POSIX tty can block waiting for carrier-detect if the
// "clocal" flag is not set. If your TTY is not connected
// to a modem, it is probably not relevant though.
// 2. We never close the FD that we open here, but the OS
// will clean up the FD for us on exit, so it doesn't
// matter. The alternative would be to have an enum of
// BorrowedFd/OwnedFd to handle both cases.
Some(f) => std::fs::OpenOptions::new()
.read(true)
.custom_flags(libc::O_NONBLOCK)
Expand Down

0 comments on commit 3df6fcb

Please sign in to comment.