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:
parent
0dc9705d7e
commit
d453f1e38a
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue