mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 14:08:31 +00:00
agent: Pass standard I/O to container launched by runk
The `kata-agent` passes its standard I/O file descriptors through to the container process that will be launched by `runk` without manipulation or modification in order to allow the container process can handle its I/O operations. Fixes: #4327 Signed-off-by: Manabu Sugimoto <Manabu.Sugimoto@sony.com>
This commit is contained in:
parent
9658c6218e
commit
5903815746
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use libc::pid_t;
|
use libc::pid_t;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::{AsRawFd, RawFd};
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
|
|
||||||
use nix::errno::Errno;
|
use nix::errno::Errno;
|
||||||
@ -137,19 +137,25 @@ impl Process {
|
|||||||
info!(logger, "before create console socket!");
|
info!(logger, "before create console socket!");
|
||||||
|
|
||||||
if !p.tty {
|
if !p.tty {
|
||||||
info!(logger, "created console socket!");
|
if cfg!(feature = "standard-oci-runtime") {
|
||||||
|
p.stdin = Some(std::io::stdin().as_raw_fd());
|
||||||
|
p.stdout = Some(std::io::stdout().as_raw_fd());
|
||||||
|
p.stderr = Some(std::io::stderr().as_raw_fd());
|
||||||
|
} else {
|
||||||
|
info!(logger, "created console socket!");
|
||||||
|
|
||||||
let (stdin, pstdin) = unistd::pipe2(OFlag::O_CLOEXEC)?;
|
let (stdin, pstdin) = unistd::pipe2(OFlag::O_CLOEXEC)?;
|
||||||
p.parent_stdin = Some(pstdin);
|
p.parent_stdin = Some(pstdin);
|
||||||
p.stdin = Some(stdin);
|
p.stdin = Some(stdin);
|
||||||
|
|
||||||
let (pstdout, stdout) = create_extended_pipe(OFlag::O_CLOEXEC, pipe_size)?;
|
let (pstdout, stdout) = create_extended_pipe(OFlag::O_CLOEXEC, pipe_size)?;
|
||||||
p.parent_stdout = Some(pstdout);
|
p.parent_stdout = Some(pstdout);
|
||||||
p.stdout = Some(stdout);
|
p.stdout = Some(stdout);
|
||||||
|
|
||||||
let (pstderr, stderr) = create_extended_pipe(OFlag::O_CLOEXEC, pipe_size)?;
|
let (pstderr, stderr) = create_extended_pipe(OFlag::O_CLOEXEC, pipe_size)?;
|
||||||
p.parent_stderr = Some(pstderr);
|
p.parent_stderr = Some(pstderr);
|
||||||
p.stderr = Some(stderr);
|
p.stderr = Some(stderr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(p)
|
Ok(p)
|
||||||
}
|
}
|
||||||
@ -284,5 +290,11 @@ mod tests {
|
|||||||
// group of the calling process.
|
// group of the calling process.
|
||||||
process.pid = 0;
|
process.pid = 0;
|
||||||
assert!(process.signal(libc::SIGCONT).is_ok());
|
assert!(process.signal(libc::SIGCONT).is_ok());
|
||||||
|
|
||||||
|
if cfg!(feature = "standard-oci-runtime") {
|
||||||
|
assert_eq!(process.stdin.unwrap(), std::io::stdin().as_raw_fd());
|
||||||
|
assert_eq!(process.stdout.unwrap(), std::io::stdout().as_raw_fd());
|
||||||
|
assert_eq!(process.stderr.unwrap(), std::io::stderr().as_raw_fd());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user