From 337959f1f4e8d1ec6977ab9acaa9018b2ea28a7c Mon Sep 17 00:00:00 2001 From: Nils Nieuwejaar Date: Thu, 20 Jan 2022 16:56:01 -0500 Subject: [PATCH] fix socketpair() implementation to build on Illumos --- filedescriptor/src/unix.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/filedescriptor/src/unix.rs b/filedescriptor/src/unix.rs index 344b4b98f..4b6cbd730 100644 --- a/filedescriptor/src/unix.rs +++ b/filedescriptor/src/unix.rs @@ -392,7 +392,12 @@ pub fn socketpair_impl() -> Result<(FileDescriptor, FileDescriptor)> { #[doc(hidden)] pub fn socketpair_impl() -> Result<(FileDescriptor, FileDescriptor)> { let mut fds = [-1i32; 2]; - let res = unsafe { libc::socketpair(libc::PF_LOCAL, libc::SOCK_STREAM, 0, fds.as_mut_ptr()) }; + #[cfg(target_os = "illumos")] + let domain = libc::AF_UNIX; + #[cfg(not(target_os = "illumos"))] + let domain = libc::PF_LOCAL; + + let res = unsafe { libc::socketpair(domain, libc::SOCK_STREAM, 0, fds.as_mut_ptr()) }; if res == -1 { Err(Error::Socketpair(std::io::Error::last_os_error())) } else {