Skip to content

Commit

Permalink
Add optimization for linux: Reopen pipe as fifo
Browse files Browse the repository at this point in the history
so that we could set `O_NONBLOCK` on it.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Apr 7, 2024
1 parent bb1cb04 commit 89432f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ impl Client {
(read_err, write_err) => {
read_err?;
write_err?;

#[cfg(target_os = "linux")]
// Optimization: Try converting it to a fifo by using /dev/fd
if let Ok(Some(jobserver)) =
Self::from_fifo(&format!("/dev/fd/{}", read.as_raw_fd()))
{
return Ok(Some(jobserver));
}
}
}

Expand Down

0 comments on commit 89432f4

Please sign in to comment.