Close stdios when fork/exec'ing virtmgr
Bug: 357611151
Test: a microdroid VM using the vm tool on adb shell.
Check the stdin/out/err of the virtmgr process. They are all /dev/null.
Change-Id: Ia71aff181402ace3b2b0861d22c04abf689fa08d
diff --git a/libs/libvmclient/src/lib.rs b/libs/libvmclient/src/lib.rs
index 7b576e6..fe86504 100644
--- a/libs/libvmclient/src/lib.rs
+++ b/libs/libvmclient/src/lib.rs
@@ -45,6 +45,7 @@
use shared_child::SharedChild;
use std::io::{self, Read};
use std::process::Command;
+use std::process::Stdio;
use std::{
fmt::{self, Debug, Formatter},
fs::File,
@@ -90,6 +91,9 @@
let (client_fd, server_fd) = posix_socketpair()?;
let mut command = Command::new(VIRTMGR_PATH);
+ command.stdin(Stdio::null());
+ command.stdout(Stdio::null());
+ command.stderr(Stdio::null());
// Can't use BorrowedFd as it doesn't implement Display
command.arg("--rpc-server-fd").arg(format!("{}", server_fd.as_raw_fd()));
command.arg("--ready-fd").arg(format!("{}", ready_fd.as_raw_fd()));