Skip to content

Commit

Permalink
add a comment about memory mapping stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
oconnor663 committed Sep 24, 2018
1 parent 118880f commit 2bc3c52
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bao_bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ fn maybe_memmap_input(in_file: &File) -> Result<Option<memmap::Mmap>, Error> {
})
}

// Note that memory mapping stdout will almost always fail for lack of read permissions, but it's
// difficult to check for that condition here. Getting the access mode of the file requires an
// operation like `libc::fcntl(..., F_GETFL) & libc::O_RDWR`, which isn't portable, so we prefer to
// just avoid calling this when we know we're using stdout. The alternative would be to catch
// permissions errors in general, which could hide bugs.
fn maybe_memmap_output(
out_file: &File,
target_len: u128,
Expand Down

0 comments on commit 2bc3c52

Please sign in to comment.