fix socketpair() implementation to build on Illumos

This commit is contained in:
Nils Nieuwejaar authored and Wez Furlong committed 2022-01-21 13:05:44 -08:00
1 parent 56e9a9af7e
commit 337959f1f4
1 file changed
+6 -1
+6 -1
View File
@@ -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 {