From d453f1e38a32bf3e5d62fc29e71009b73fe67cb6 Mon Sep 17 00:00:00 2001 From: Liu Jiang Date: Tue, 15 Feb 2022 12:32:28 +0800 Subject: [PATCH] runc: implement Io for Arc Add an implementation of `impl Io for Arc`. Signed-off-by: Liu Jiang --- crates/runc/src/io.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/runc/src/io.rs b/crates/runc/src/io.rs index 95493fe..29277fe 100644 --- a/crates/runc/src/io.rs +++ b/crates/runc/src/io.rs @@ -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 Io for Arc { + fn stdin(&self) -> Option { + self.deref().stdin() + } + + fn stdout(&self) -> Option { + self.deref().stdout() + } + + fn stderr(&self) -> Option { + 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,