Skip to content

Commit

Permalink
fix os_pipe doesn't work with async IO
Browse files Browse the repository at this point in the history
  • Loading branch information
ningmingxiao authored and mxpv committed Oct 21, 2024
1 parent 7794b07 commit a6b4286
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/runc/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ use std::{
fmt::Debug,
fs::{File, OpenOptions},
io::Result,
os::unix::{fs::OpenOptionsExt, io::AsRawFd},
os::unix::{
fs::OpenOptionsExt,
io::{AsRawFd, OwnedFd},
},
process::Stdio,
sync::Mutex,
};

use log::debug;
use nix::unistd::{Gid, Uid};
use os_pipe::{PipeReader, PipeWriter};
#[cfg(feature = "async")]
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::unix::pipe;

use crate::Command;

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

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

impl Pipe {
fn new() -> std::io::Result<Self> {
let (rd, wr) = os_pipe::pipe()?;
let (tx, rx) = pipe::pipe()?;
let rd = tx.into_blocking_fd()?;
let wr = rx.into_blocking_fd()?;
Ok(Self { rd, wr })
}
}
Expand Down

0 comments on commit a6b4286

Please sign in to comment.