Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mark close_range I/O unsafe
  • Loading branch information
Chris Pick committed Oct 5, 2023
commit 3e5d88108d100b0c8f8483a4871d21d323eed1e1
6 changes: 3 additions & 3 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ libc_bitflags! {
/// use nix::unistd::{close_range, CloseRangeFlags};
///
/// let f = tempfile::tempfile().unwrap();
/// close_range(f.as_raw_fd(), f.as_raw_fd(), CloseRangeFlags::empty()).unwrap(); // Bad! f will also close on drop!
/// unsafe { close_range(f.as_raw_fd(), f.as_raw_fd(), CloseRangeFlags::empty()).unwrap() }; // Bad! f will also close on drop!
/// ```
///
/// ```rust
Expand All @@ -1133,10 +1133,10 @@ libc_bitflags! {
///
/// let f = tempfile::tempfile().unwrap();
/// let fd = f.into_raw_fd(); // Good. into_raw_fd consumes f
/// close_range(fd, fd, CloseRangeFlags::empty()).unwrap();
/// unsafe { close_range(fd, fd, CloseRangeFlags::empty()).unwrap(); }
/// ```
#[cfg(target_os = "linux")]
pub fn close_range(
pub unsafe fn close_range(
first: RawFd,
last: RawFd,
flags: CloseRangeFlags,
Expand Down