In the nix crate, nix::pty::PtyMaster doesn't have .as_raw_fd()?

Hello everyone :wave:

So I got a MasterPty like this :

let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();

And now I would like to call close on it, from a forked child process. the nix::unistd::close() function accepts a RawFd as a parameter, and in the documentation, here : https://docs.rs/nix/0.17.0/nix/pty/struct.PtyMaster.html, it says that MasterPty implements AsRawFd. But when I try to call .as_raw_fd() on my PtyMaster, the compiler says this :

221 |                 close(master_fd.as_raw_fd());
    |                                 ^^^^^^^^^ method not found in `nix::pty::PtyMaster`

What should I do ?

Ps apparently, RawFd is marked as private, but that doesn't help much...

had to use this crate :
use std::os::unix::io::AsRawFd;

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.