pub struct CmdFds { /* private fields */ }Expand description
File descriptor allocator for child processes.
Collects fd assignments and optional systemd socket-activation
configuration, then applies them all at once via
CapStdExtCommandExt::take_fds.
new_systemd_fdscreates an allocator with systemd socket-activation fds at 3, 4, … (SD_LISTEN_FDS_START).take_fdauto-assigns the next fd above all previously assigned ones (minimum 3).take_fd_nplaces an fd at an explicit number, panicking on overlap.
let mut cmd = std::process::Command::new("myservice");
let mut fds = CmdFds::new_systemd_fds([(varlink_fd, SystemdFdName::new("varlink"))]);
let extra_n = fds.take_fd(extra_fd);
cmd.take_fds(fds);Implementations§
Source§impl CmdFds
impl CmdFds
Sourcepub fn new_systemd_fds<'a>(
fds: impl IntoIterator<Item = (Arc<OwnedFd>, SystemdFdName<'a>)>,
) -> Self
pub fn new_systemd_fds<'a>( fds: impl IntoIterator<Item = (Arc<OwnedFd>, SystemdFdName<'a>)>, ) -> Self
Create a new fd allocator with systemd socket-activation fds.
Each (fd, name) pair is assigned a consecutive fd number starting
at SD_LISTEN_FDS_START (3). The LISTEN_PID, LISTEN_FDS, and
LISTEN_FDNAMES environment variables will be set in the child
when CapStdExtCommandExt::take_fds is called.
Additional (non-systemd) fds can be registered afterwards via
take_fd or take_fd_n.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CmdFds
impl RefUnwindSafe for CmdFds
impl Send for CmdFds
impl Sync for CmdFds
impl Unpin for CmdFds
impl UnsafeUnpin for CmdFds
impl UnwindSafe for CmdFds
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more