Skip to content

Commit

Permalink
temporal: try fix musl, return old code
Browse files Browse the repository at this point in the history
  • Loading branch information
belovdv committed Jan 20, 2024
1 parent 3951e34 commit 323e098
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,39 @@ impl Client {

unsafe fn mk() -> io::Result<(Client, String)> {
let mut pipes = [0; 2];

// Attempt atomically-create-with-cloexec if we can on Linux,
// detected by using the `syscall` function in `libc` to try to work
// with as many kernels/glibc implementations as possible.
#[cfg(target_os = "linux")]
{
use std::sync::atomic::{AtomicBool, Ordering};

static PIPE_AVAILABLE: AtomicBool = AtomicBool::new(true);
if PIPE_AVAILABLE.load(Ordering::SeqCst) {
match libc::syscall(libc::SYS_pipe, pipes.as_mut_ptr()) {
-1 => {
let err = io::Error::last_os_error();
if err.raw_os_error() == Some(libc::ENOSYS) {
PIPE_AVAILABLE.store(false, Ordering::SeqCst);
} else {
return Err(err);
}
}
_ => {
let string_arg = format!(
"--jobserver-fds={},{}",
pipes[0].as_raw_fd(),
pipes[1].as_raw_fd()
);
return Ok((Client::from_fds(pipes[0], pipes[1]), string_arg));
}
}
}
}

cvt(libc::pipe(pipes.as_mut_ptr()))?;

let string_arg = format!(
"--jobserver-fds={},{}",
pipes[0].as_raw_fd(),
Expand Down

0 comments on commit 323e098

Please sign in to comment.