-
Notifications
You must be signed in to change notification settings - Fork 29
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
Replace direct dependency on libc with rustix #31
Conversation
``` warning: the borrowed expression implements the required traits --> tests/std.rs:311:29 | 311 | cmd.env("PATH", &p); | ^^ help: change this to: `p` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
src/lib.rs
Outdated
syscall!(fcntl(fd, libc::F_SETFL, res & !libc::O_NONBLOCK)); | ||
|
||
fn blocking_fd(fd: rustix::fd::BorrowedFd<'_>) -> io::Result<()> { | ||
let flags = rustix::fs::fcntl_getfl(fd)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That behavior in the standard library seems to have been introduced in rust-lang/rust@efeb42b.
I wondered why it is linux-only, since FIONBIO is available on several other unix-like systems. After a little looking into it, in the standard library it seems mainly because it could not find docs on other operating systems (rust-lang/rust#39514 (comment)), and also this comment in libuv indicates that there are cases where it is not supported, at least on BSD. Also, this commit in mio indicates that it is not working as we expected on illumos.
So, for now, it seems to make sense to do it only on linux.
763e435
to
c9b6b0b
Compare
related: smol-rs/async-io#76