Skip to content

Commit a6b4286

Browse files
ningmingxiaomxpv
authored andcommitted
fix os_pipe doesn't work with async IO
1 parent 7794b07 commit a6b4286

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/runc/src/io.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ use std::{
1919
fmt::Debug,
2020
fs::{File, OpenOptions},
2121
io::Result,
22-
os::unix::{fs::OpenOptionsExt, io::AsRawFd},
22+
os::unix::{
23+
fs::OpenOptionsExt,
24+
io::{AsRawFd, OwnedFd},
25+
},
2326
process::Stdio,
2427
sync::Mutex,
2528
};
2629

2730
use log::debug;
2831
use nix::unistd::{Gid, Uid};
29-
use os_pipe::{PipeReader, PipeWriter};
3032
#[cfg(feature = "async")]
3133
use tokio::io::{AsyncRead, AsyncWrite};
34+
use tokio::net::unix::pipe;
3235

3336
use crate::Command;
3437

@@ -100,8 +103,8 @@ impl Default for IOOption {
100103
/// When one side of the pipe is closed, the state will be represented with [`None`].
101104
#[derive(Debug)]
102105
pub struct Pipe {
103-
rd: PipeReader,
104-
wr: PipeWriter,
106+
rd: OwnedFd,
107+
wr: OwnedFd,
105108
}
106109

107110
#[derive(Debug)]
@@ -113,7 +116,9 @@ pub struct PipedIo {
113116

114117
impl Pipe {
115118
fn new() -> std::io::Result<Self> {
116-
let (rd, wr) = os_pipe::pipe()?;
119+
let (tx, rx) = pipe::pipe()?;
120+
let rd = tx.into_blocking_fd()?;
121+
let wr = rx.into_blocking_fd()?;
117122
Ok(Self { rd, wr })
118123
}
119124
}

0 commit comments

Comments
 (0)