summaryrefslogtreecommitdiffstats
path: root/third_party/rust/nix/src/pty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/nix/src/pty.rs')
-rw-r--r--third_party/rust/nix/src/pty.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/third_party/rust/nix/src/pty.rs b/third_party/rust/nix/src/pty.rs
index 455828b703..74f8ecf0df 100644
--- a/third_party/rust/nix/src/pty.rs
+++ b/third_party/rust/nix/src/pty.rs
@@ -71,7 +71,7 @@ impl io::Read for PtyMaster {
impl io::Write for PtyMaster {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- unistd::write(self.0.as_raw_fd(), buf).map_err(io::Error::from)
+ unistd::write(&self.0, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
@@ -86,7 +86,7 @@ impl io::Read for &PtyMaster {
impl io::Write for &PtyMaster {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- unistd::write(self.0.as_raw_fd(), buf).map_err(io::Error::from)
+ unistd::write(&self.0, buf).map_err(io::Error::from)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
@@ -169,12 +169,12 @@ pub fn posix_openpt(flags: fcntl::OFlag) -> Result<PtyMaster> {
/// For a threadsafe and non-`unsafe` alternative on Linux, see `ptsname_r()`.
#[inline]
pub unsafe fn ptsname(fd: &PtyMaster) -> Result<String> {
- let name_ptr = libc::ptsname(fd.as_raw_fd());
+ let name_ptr = unsafe { libc::ptsname(fd.as_raw_fd()) };
if name_ptr.is_null() {
return Err(Errno::last());
}
- let name = CStr::from_ptr(name_ptr);
+ let name = unsafe { CStr::from_ptr(name_ptr) };
Ok(name.to_string_lossy().into_owned())
}
@@ -187,8 +187,7 @@ pub unsafe fn ptsname(fd: &PtyMaster) -> Result<String> {
///
/// This value is useful for opening the slave ptty once the master has already been opened with
/// `posix_openpt()`.
-#[cfg(any(target_os = "android", target_os = "linux"))]
-#[cfg_attr(docsrs, doc(cfg(all())))]
+#[cfg(linux_android)]
#[inline]
pub fn ptsname_r(fd: &PtyMaster) -> Result<String> {
let mut name_buf = Vec::<libc::c_char>::with_capacity(64);
@@ -342,7 +341,7 @@ pub unsafe fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b T
.map(|ws| ws as *const Winsize as *mut _)
.unwrap_or(ptr::null_mut());
- let res = libc::forkpty(master.as_mut_ptr(), ptr::null_mut(), term, win);
+ let res = unsafe { libc::forkpty(master.as_mut_ptr(), ptr::null_mut(), term, win) };
let fork_result = Errno::result(res).map(|res| match res {
0 => ForkResult::Child,
@@ -350,7 +349,7 @@ pub unsafe fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b T
})?;
Ok(ForkptyResult {
- master: OwnedFd::from_raw_fd(master.assume_init()),
+ master: unsafe { OwnedFd::from_raw_fd( master.assume_init() ) },
fork_result,
})
}