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 committed Oct 11, 2024
1 parent 7794b07 commit f3ccee6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/runc/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ use std::{

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

use crate::Command;
use std::os::unix::io::OwnedFd;
use tokio::net::unix::pipe;

pub trait Io: Debug + Send + Sync {
/// Return write side of stdin
Expand Down Expand Up @@ -100,8 +101,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 +114,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 f3ccee6

Please sign in to comment.