runc: implement Io for Arc<T: Io>

Add an implementation of `impl<T: Io> Io for Arc<T>`.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
Liu Jiang 2022-02-15 12:32:28 +08:00
parent 0dc9705d7e
commit d453f1e38a
1 changed files with 24 additions and 1 deletions

View File

@ -16,8 +16,9 @@
use std::fmt::{self, Debug, Formatter};
use std::fs::File;
use std::io::Result;
use std::ops::Deref;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::sync::Mutex;
use std::sync::{Arc, Mutex};
use nix::unistd::{Gid, Uid};
@ -53,6 +54,28 @@ impl Debug for dyn Io {
}
}
impl<T: Io> Io for Arc<T> {
fn stdin(&self) -> Option<File> {
self.deref().stdin()
}
fn stdout(&self) -> Option<File> {
self.deref().stdout()
}
fn stderr(&self) -> Option<File> {
self.deref().stderr()
}
fn set(&self, cmd: &mut Command) -> Result<()> {
self.deref().set(cmd)
}
fn close_after_start(&self) {
self.deref().close_after_start()
}
}
#[derive(Debug, Clone)]
pub struct IOOption {
pub open_stdin: bool,