diff --git a/src/lib.rs b/src/lib.rs index 9498b5289..98be65394 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,12 +5,12 @@ extern crate quickcheck; pub mod capabilities; pub mod cgroups; pub mod command; -pub mod cond; pub mod container; pub mod create; pub mod logger; pub mod namespaces; pub mod notify_socket; +pub mod pipe; pub mod process; pub mod rootfs; pub mod signal; diff --git a/src/cond.rs b/src/pipe.rs similarity index 71% rename from src/cond.rs rename to src/pipe.rs index 2ec86cb23..53518eee2 100644 --- a/src/cond.rs +++ b/src/pipe.rs @@ -1,4 +1,4 @@ -//! Conditional variable that performs busy waiting on lock +//! Unix pipe wrapper use std::os::unix::io::RawFd; @@ -6,16 +6,16 @@ use anyhow::Result; use nix::fcntl::OFlag; use nix::unistd::{close, pipe2, read}; -pub struct Cond { +pub struct Pipe { rfd: RawFd, wfd: RawFd, } -impl Cond { - pub fn new() -> Result { +impl Pipe { + pub fn new() -> Result { // Sets as close-on-execution - let (rfd, wfd) = pipe2(OFlag::O_CLOEXEC)?; - Ok(Cond { rfd, wfd }) + let (rfd, wfd) = pipe2(OFlag::O_CLOEXEC)?; + Ok(Pipe { rfd, wfd }) } pub fn wait(&self) -> Result<()> { diff --git a/src/process/fork.rs b/src/process/fork.rs index afa3d8ab5..9689dacff 100644 --- a/src/process/fork.rs +++ b/src/process/fork.rs @@ -16,7 +16,7 @@ use nix::unistd::Pid; use crate::cgroups::common::CgroupManager; use crate::container::ContainerStatus; use crate::process::{child, init, parent, Process}; -use crate::{cond::Cond, container::Container}; +use crate::{container::Container, pipe::Pipe}; /// Function to perform the first fork for in order to run the container process pub fn fork_first>( @@ -27,7 +27,7 @@ pub fn fork_first>( cmanager: Box, ) -> Result { // create a new pipe - let ccond = Cond::new()?; + let cpipe = Pipe::new()?; // create new parent process structure let (mut parent, sender_for_parent) = parent::ParentProcess::new()?; @@ -55,12 +55,12 @@ pub fn fork_first>( sched::unshare(sched::CloneFlags::CLONE_NEWUSER)?; } - ccond.notify()?; + cpipe.notify()?; Ok(Process::Child(child)) } // in the parent process unistd::ForkResult::Parent { child } => { - ccond.wait()?; + cpipe.wait()?; // wait for child to fork init process and report back its pid let init_pid = parent.wait_for_child_ready()?;