Skip to content

Commit 1d364a7

Browse files
committed
Move to std pipe
1 parent b60b002 commit 1d364a7

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tokio = { version = "1", features = ["full"] }
1717
tokio-stream = "0.1"
1818
async-stream = "0.3"
1919
udev = "0.9"
20-
rustix = { version = "1", features = ["fs", "stdio", "process", "thread", "pipe", "mount", "net"] }
20+
rustix = { version = "1", features = ["fs", "stdio", "process", "thread", "mount", "net"] }
2121
bitflags = "2"
2222
humantime = "2"
2323
serde = { version = "1", features = ["derive"] }

src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use hotplug::{AttachedDevice, HotPlug};
1010

1111
use std::fmt::Display;
1212
use std::fs::File;
13+
use std::io::{PipeWriter, Read};
1314
use std::mem::ManuallyDrop;
1415
use std::os::unix::process::CommandExt;
1516
use std::pin::pin;
@@ -21,8 +22,6 @@ use clap::Parser;
2122
use log::info;
2223
use runc::Container;
2324
use runc::cli::{CreateOptions, GlobalOptions};
24-
use rustix::fd::OwnedFd;
25-
use rustix::pipe::PipeFlags;
2625
use rustix::process::Signal;
2726
use tokio_stream::StreamExt;
2827

@@ -53,7 +52,7 @@ impl Display for Event {
5352
}
5453
}
5554

56-
async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd) -> Result<()> {
55+
async fn create(global: GlobalOptions, create: CreateOptions, notifier: PipeWriter) -> Result<()> {
5756
let mut notifier = Some(notifier);
5857

5958
let config = runc::config::Config::from_bundle(&create.bundle)?;
@@ -226,15 +225,15 @@ fn do_main() -> Result<()> {
226225
// However for early forking, we need to know whether a container is successfully created.
227226
// We do this by creating a pipe. The pipe can be closed by either the child process exiting,
228227
// or the child process closing it.
229-
let (parent, child) = rustix::pipe::pipe_with(PipeFlags::CLOEXEC)?;
228+
let (mut parent, child) = std::io::pipe()?;
230229
match safe_fork::fork().expect("should still be single-threaded") {
231230
None => {
232231
drop(parent);
233232
tokio::runtime::Runtime::new()?.block_on(create(args.global, create_options, child))?;
234233
}
235234
Some(pid) => {
236235
drop(child);
237-
if rustix::io::read(parent, &mut [0])? == 0 {
236+
if parent.read(&mut [0])? == 0 {
238237
// In this case, the child process exited before notifying us.
239238
std::process::exit(pid.join()?.code().unwrap_or(1) as _);
240239
}

0 commit comments

Comments
 (0)