diff options
author | Jesse Luehrs <doy@tozt.net> | 2023-08-06 18:48:27 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2023-08-06 18:48:27 -0400 |
commit | 461ba4de3a9996506682351d127ee9e0eed79fb2 (patch) | |
tree | 967e53fc322f7ecae08cc959e219407f72184d09 | |
parent | 54e8bf4f2e91407be2054cd38fea81ba830303fd (diff) | |
download | pty-process-461ba4de3a9996506682351d127ee9e0eed79fb2.tar.gz pty-process-461ba4de3a9996506682351d127ee9e0eed79fb2.zip |
fix build on macos
-rw-r--r-- | src/sys.rs | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -9,13 +9,16 @@ pub struct Pty(std::os::fd::OwnedFd); impl Pty { pub fn open() -> crate::Result<Self> { let pt = rustix::pty::openpt( - rustix::pty::OpenptFlags::RDWR - | rustix::pty::OpenptFlags::NOCTTY - | rustix::pty::OpenptFlags::CLOEXEC, + // can't use CLOEXEC here because it's linux-specific + rustix::pty::OpenptFlags::RDWR | rustix::pty::OpenptFlags::NOCTTY, )?; rustix::pty::grantpt(&pt)?; rustix::pty::unlockpt(&pt)?; + let mut flags = rustix::io::fcntl_getfd(&pt)?; + flags |= rustix::io::FdFlags::CLOEXEC; + rustix::io::fcntl_setfd(&pt, flags)?; + Ok(Self(pt)) } @@ -31,7 +34,9 @@ impl Pty { ); if ret == -1 { Err(rustix::io::Errno::from_raw_os_error( - *libc::__errno_location(), + std::io::Error::last_os_error() + .raw_os_error() + .unwrap_or(0), ) .into()) } else { |