aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-08-06 18:48:27 -0400
committerJesse Luehrs <doy@tozt.net>2023-08-06 18:48:27 -0400
commit461ba4de3a9996506682351d127ee9e0eed79fb2 (patch)
tree967e53fc322f7ecae08cc959e219407f72184d09
parent54e8bf4f2e91407be2054cd38fea81ba830303fd (diff)
downloadpty-process-461ba4de3a9996506682351d127ee9e0eed79fb2.tar.gz
pty-process-461ba4de3a9996506682351d127ee9e0eed79fb2.zip
fix build on macos
-rw-r--r--src/sys.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sys.rs b/src/sys.rs
index 878a374..c3d633c 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -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 {