Skip to content

Commit 2d32459

Browse files
committed
Renamed Cond to Pipe
1 parent ea5b8f9 commit 2d32459

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Diff for: src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ extern crate quickcheck;
55
pub mod capabilities;
66
pub mod cgroups;
77
pub mod command;
8-
pub mod cond;
98
pub mod container;
109
pub mod create;
1110
pub mod logger;
1211
pub mod namespaces;
1312
pub mod notify_socket;
13+
pub mod pipe;
1414
pub mod process;
1515
pub mod rootfs;
1616
pub mod signal;

Diff for: src/cond.rs renamed to src/pipe.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
//! Conditional variable that performs busy waiting on lock
1+
//! Unix pipe wrapper
22
33
use std::os::unix::io::RawFd;
44

55
use anyhow::Result;
66
use nix::fcntl::OFlag;
77
use nix::unistd::{close, pipe2, read};
88

9-
pub struct Cond {
9+
pub struct Pipe {
1010
rfd: RawFd,
1111
wfd: RawFd,
1212
}
1313

14-
impl Cond {
15-
pub fn new() -> Result<Cond> {
14+
impl Pipe {
15+
pub fn new() -> Result<Self> {
1616
// Sets as close-on-execution
17-
let (rfd, wfd) = pipe2(OFlag::O_CLOEXEC)?;
18-
Ok(Cond { rfd, wfd })
17+
let (rfd, wfd) = pipe2(OFlag::O_CLOEXEC)?;
18+
Ok(Pipe { rfd, wfd })
1919
}
2020

2121
pub fn wait(&self) -> Result<()> {

Diff for: src/process/fork.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use nix::unistd::Pid;
1616
use crate::cgroups::common::CgroupManager;
1717
use crate::container::ContainerStatus;
1818
use crate::process::{child, init, parent, Process};
19-
use crate::{cond::Cond, container::Container};
19+
use crate::{container::Container, pipe::Pipe};
2020

2121
/// Function to perform the first fork for in order to run the container process
2222
pub fn fork_first<P: AsRef<Path>>(
@@ -27,7 +27,7 @@ pub fn fork_first<P: AsRef<Path>>(
2727
cmanager: Box<dyn CgroupManager>,
2828
) -> Result<Process> {
2929
// create a new pipe
30-
let ccond = Cond::new()?;
30+
let cpipe = Pipe::new()?;
3131

3232
// create new parent process structure
3333
let (mut parent, sender_for_parent) = parent::ParentProcess::new()?;
@@ -55,12 +55,12 @@ pub fn fork_first<P: AsRef<Path>>(
5555
sched::unshare(sched::CloneFlags::CLONE_NEWUSER)?;
5656
}
5757

58-
ccond.notify()?;
58+
cpipe.notify()?;
5959
Ok(Process::Child(child))
6060
}
6161
// in the parent process
6262
unistd::ForkResult::Parent { child } => {
63-
ccond.wait()?;
63+
cpipe.wait()?;
6464

6565
// wait for child to fork init process and report back its pid
6666
let init_pid = parent.wait_for_child_ready()?;

0 commit comments

Comments
 (0)