Revision control

Copy as Markdown

Other Tools

//! POSIX shared memory
use crate::fd::OwnedFd;
use crate::{backend, io, path};
pub use crate::backend::fs::types::Mode;
pub use crate::backend::shm::types::ShmOFlags;
/// `shm_open(name, oflags, mode)`—Opens a shared memory object.
///
/// For portability, `name` should begin with a slash, contain no other
/// slashes, and be no longer than an implementation-defined limit (255 on
/// Linux).
///
/// Exactly one of [`ShmOFlags::RDONLY`] and [`ShmOFlags::RDWR`] should be
/// passed. The file descriptor will be opened with `FD_CLOEXEC` set.
///
/// # References
/// - [POSIX]
/// - [Linux]
///
#[inline]
pub fn shm_open<P: path::Arg>(name: P, flags: ShmOFlags, mode: Mode) -> io::Result<OwnedFd> {
name.into_with_c_str(|name| backend::shm::syscalls::shm_open(name, flags, mode))
}
/// `shm_unlink(name)`—Unlinks a shared memory object.
///
/// # References
/// - [POSIX]
/// - [Linux]
///
#[inline]
pub fn shm_unlink<P: path::Arg>(name: P) -> io::Result<()> {
name.into_with_c_str(backend::shm::syscalls::shm_unlink)
}